Set properties for current table only

I have a table with lots of columns. Rather than set each one of them to sortable individually I am using the following: public function boot() { TextColumn::configureUsing(function (TextColumn $textColumn): void { $textColumn->sortable(); }); } However this isn't ideal since it sets the property globally and might affect other tables elsewhere in the system. Is there a way to limit the scope only to one particular table?
1 Reply
DrByte
DrByte6mo ago
I suppose you could inspect the route to be matching a resource, by adding something like this (or maybe check an array) in the beginning of your closure:
if (! request()->routeIs('filament.app.resources.concerts.*')) {
return;
}
$textColumn->sortable();
if (! request()->routeIs('filament.app.resources.concerts.*')) {
return;
}
$textColumn->sortable();
You might also be able to restrict it per-panel by moving it to ->bootUsing() on that/each panel.