dvarilek/filament-table-select
Installation:
composer require dvarilek/filament-table-select:^2.0.7
Publish the config (optional):
php artisan vendor:publish --provider="Dvarilek\FilamentTableSelect\FilamentTableSelectServiceProvider"
First Use Case:
Replace a standard Select field in a Filament form with TableSelect for a related model.
Example in a resource's Form class:
use Dvarilek\FilamentTableSelect\Forms\Components\TableSelect;
TableSelect::make('user_id')
->relationship('users') // BelongsTo relationship
->column('name') // Display column
->searchable()
->required(),
Where to Look First:
config/filament-table-select.php for global defaults (e.g., table styling, search behavior).src/Forms/Components/TableSelect.php for method reference and customization hooks.Basic Relationship Handling:
->relationship('posts') for hasMany/belongsTo relationships.->polymorphic() and specify the relatedKey/foreignKey.Table Customization:
TableSelect::make('author_id')
->relationship('authors')
->tableColumns([
Tables\Columns\TextColumn::make('name'),
Tables\Columns\IconColumn::make('verified')->boolean(),
]),
->tableUsing(AuthorTable::class),
Search and Filtering:
->searchable()
->searchDebounce(300),
->tableFilters([
'is_active' => fn (Tables\Filters\Filter $filter) => $filter->toggle(),
]),
Multi-Select:
TableSelect::make('tags')
->relationship('tags')
->multiple()
->preload(),
Integration with Existing Forms:
Form and Table components.->required(), ->rules()).Dynamic Relationships:
->relationship(fn () => $this->getDynamicRelation())
Useful for conditional logic (e.g., tenant-specific relations).
Custom Table Actions: Add actions to the select table:
->tableActions([
Tables\Actions\EditAction::make(),
]),
Lazy Loading:
Use ->preload() to eager-load relationships and reduce N+1 queries.
Conditional Rendering:
->visible(fn ($record) => $record->canSelectAuthors())
Performance:
->searchable() + ->searchDebounce() and paginate the table:
->tablePagination(10),
with() method.Relationship Mismatches:
Undefined relationship errors if the relationship name doesn’t match.->relationship('posts') for $this->posts()).Caching:
php artisan filament:cache-reset
Polymorphic Relations:
relatedKey and foreignKey:
->polymorphic()
->relatedKey('authorable_id')
->foreignKey('authorable_type'),
Log Table Queries: Enable Laravel’s query logging to debug slow tables:
->tableUsing(fn () => {
$table = AuthorTable::make();
$table->queryLog = true; // Custom property to inspect queries
return $table;
}),
Check Config Overrides:
Ensure no global config in config/filament-table-select.php conflicts with your component settings.
Inspect Rendered HTML: Use browser dev tools to verify the table structure and identify missing CSS/JS.
Custom Table Classes:
Extend Filament\Tables\Table to add reusable logic:
class CustomAuthorTable extends Table {
public function getTableSelectQuery(): Builder {
return parent::getTableSelectQuery()->where('is_active', true);
}
}
Event Hooks:
Listen for filament-table-select.rendered events to modify the table after initialization.
Blade Overrides:
Override the default table view in resources/views/vendor/filament-table-select/table.blade.php.
Localization:
Extend the package’s language lines in resources/lang/en/filament-table-select.php.
->tableUsing() for Complex Tables:
For tables with custom actions, bulk actions, or complex filters, define a dedicated table class.->tableActions() to enable inline editing/deletion of selected records.->tableColumns() to include Filament’s rich columns (e.g., BadgeColumn, ToggleColumn).How can I help you explore Laravel packages today?