Preventing the admin from deleting himself

5 Replies
darrenglanville
darrenglanville5mo ago
Are you using rules? You can add a false in it if the $user != Auth()->user()
atabegruslan
atabegruslanOP5mo ago
The first idea worked. The second idea also sounds good, but where in the code is the rules? And a related Q: In the Edit view: Actions\DeleteAction::make() How can I disable or not show the delete button for the admin? like, inside this file:
class EditUser extends EditRecord
{
protected static string $resource = UserResource::class;

protected function getHeaderActions(): array
{
return [
Actions\ViewAction::make(),
Actions\DeleteAction::make()
class EditUser extends EditRecord
{
protected static string $resource = UserResource::class;

protected function getHeaderActions(): array
{
return [
Actions\ViewAction::make(),
Actions\DeleteAction::make()
I dont know how to get the id of the current user page. How do you grab the {id} from this url? {domain}/admin/users/{id}/edit Once I know that I can :
if ($id !== Auth::id())
{
Actions\DeleteAction::make()
}
if ($id !== Auth::id())
{
Actions\DeleteAction::make()
}
LeandroFerreira
LeandroFerreira5mo ago
->hidden(fn (User $record): bool => $record->id === auth()->id())
->hidden(fn (User $record): bool => $record->id === auth()->id())
Want results from more Discord servers?
Add your server