update actions on filter change

How can i update an action, when a filter is changed? I have an action, which is showing in a table column. The action shows labels with links, depending on the selection in the form of the filter. My problem is, that if i change the filter, the actions are not updated. I have to make a cmd-r reload of the page, to force a new calculation of the action label. How can i resolve this please?
6 Replies
Saade
Saade12mo ago
use a closure to access the $tableFilters livewire property
fn ($livewire) => data_get($livewire->tableFilters, 'your_filter_name.value')
fn ($livewire) => data_get($livewire->tableFilters, 'your_filter_name.value')
then do whatever you want with this information
Falk Maria Zeitsprung
thanks @saadeguilherme Thank you very much! I am new. Could you please help me where to put this as a small example please?
Saade
Saade12mo ago
how's your url looking like? copy-paste here please
Saade
Saade12mo ago
in your case, replace request()->input('tableFilters.Center.userId') in your code with:
data_get($livewire->tableFilters, 'Center.userId')
data_get($livewire->tableFilters, 'Center.userId')
Action::make('makeReservation')
->label(function ($livewire, Availability $record) {
$userId = data_get($livewire->tableFilters, 'Center.userId');
});
Action::make('makeReservation')
->label(function ($livewire, Availability $record) {
$userId = data_get($livewire->tableFilters, 'Center.userId');
});
Falk Maria Zeitsprung
Works Perfect @saadeguilherme !! 🤩 Wow. Really great!!! Thanks very very much.