Show disabled EditAction instead of hide it to user who can't edit the record.

I've added canEdit() method in a BookResource to control authorization for the EditAction in an application built with Filament v2:
public static function canEdit(Model $record): bool
{
return $record->hasAccess();
}
public static function canEdit(Model $record): bool
{
return $record->hasAccess();
}
This is hiding the action completely, but I want to instead show the action disabled to users that can't edit the record.
Tables\Actions\EditAction::make()
->disabled(fn (Model $record): bool => ! $record->hasAccess()),
Tables\Actions\EditAction::make()
->disabled(fn (Model $record): bool => ! $record->hasAccess()),
Can someone help me with this? ->visible(fn (Model $record): bool => $record->hasAccess()) don't work. The model's hasAccess() method will perform this check:
auth()->user()->is_admin || auth()->user()->id == $record->user_id
auth()->user()->is_admin || auth()->user()->id == $record->user_id
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server