Luc Van Keer
Where is the Filament\Actions\Concerns\CanBeHidden::authorize() method in the documentation ?
Excuses for the late answer. You can use the visible() or hidden() to conditionally show/hide the action button.
In the ->action() method you can call a method on your livewire component where you can actually check the authorization.
Something like:
->action(fn(array $data, Clubmember $record, EditClubmember $livewire) => $livewire->changeDepartment($record, $data)),
public function changeDepartment(Clubmember $record, array $data): void
{
if (!filament()->auth()->user()->can('update_dept_clubmember', $record)) {
return;
}
$record->departments = $data['departments'];
$record->save();
}
10 replies
Conditionally show a dashboard page
The panel initialisation is triggered from the register method of the laravel provider. Since the user is established in the middleware pipeline, it is not available.
I would solve this with a custom middleware (which can be added in the panel construction).
18 replies