In this example, we will show you how to create a Dynamic Filament resource table column using another model.
In this example, we require displaying a "Quick Action" to select which Country has the Product available.
For this, we need a few models:
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{ // ...}