Show table action only when a specific filter is set

I would like to display a table action, but only when a specific filter is selected. This works on the first request and there is a filter value in the GET:
Tables\Actions\Action::make('testactio')
->visible(function(){
$filter = request()->get('tableFilters');
if(isset($filter['verplichte_cursus']) && $filter['verplichte_cursus']){
return true;
}
Tables\Actions\Action::make('testactio')
->visible(function(){
$filter = request()->get('tableFilters');
if(isset($filter['verplichte_cursus']) && $filter['verplichte_cursus']){
return true;
}
But won't work when we select the filter after the page loads. I tried injecting
$get
$get
but it can't resolve that. Is there a way to do this?
1 Reply
Patrick
PatrickOP9mo ago
Found a solution. We can fetch it from the Livewire instance.
Tables\Actions\Action::make('testactio')
->visible(function($livewire){
return isset($livewire->tableFilters['verplichte_cursus']['value']) && $livewire->tableFilters['verplichte_cursus']['value'];
})])
Tables\Actions\Action::make('testactio')
->visible(function($livewire){
return isset($livewire->tableFilters['verplichte_cursus']['value']) && $livewire->tableFilters['verplichte_cursus']['value'];
})])
Want results from more Discord servers?
Add your server