Dynamic Table Fields with Database Actions

Filament 4/5

In this example, we will show you how to create a Dynamic Filament resource table column using another model.

FilamentExamples ThumbBase (16)

Get the Source Code:

Only This Example

$9

One-time payment

Full source code for Dynamic Table Fields with Database Actions
Downloadable ZIP file with the source code
Lifetime access to this example
GitHub Sign in with GitHub to buy

Sign in first, then complete your $9 checkout.

Best value — all 169 examples

FilamentExamples Membership

$99 /year
or
$199 lifetime
Access to code of all 169 examples
Future new examples and updates included
FilaCheck Pro package licence included
MCP server included
View membership plans

30-day money-back guarantee

How it works

In this example, we require displaying a "Quick Action" to select which Country has the Product available.

For this, we need a few models:

  • Products - Our products list
  • Countries - Our countries list
  • Product Countries - An intermediate model, where we store selected data

Our main code will be inside our ProductTable file:

app/Filament/Resources/Products/Tables/ProductsTable.php

class ProductsTable
{
public static function configure(Table $table): Table
{
return $table
->columns([
TextColumn::make('id'),
TextColumn::make('name'),
])
->filters([
//
])
->recordActions([
ViewAction::make(),
EditAction::make(),
])
->toolbarActions([
BulkActionGroup::make([
DeleteBulkAction::make(),
]),
]);
}
}

Here, we want to dynamically display the checkboxes for each country. This can be done using arrays:

app/Filament/Resources/Products/Tables/ProductsTable.php

class ProductsTable
{
// ...
}
The FULL tutorial is available after the purchase: in the Readme file of the official repository you would get invited to.