Skip to content

How can remove the row delete button if record match some conditions in ModelResource #1427

Answered by lee-to
WillieOng-HK asked this question in Q&A
Discussion options

You must be logged in to vote

We already have a package based on spatie with support for version 3
https://github.com/SWEET1S/moonshine-roles-permissions

If you still want to implement it yourself, here are the materials

https://moonshine-laravel.com/en/docs/3.x/model-resource/authorization

https://moonshine-laravel.com/en/docs/3.x/security/authorization#additional_logic

You can also just hide the button
https://moonshine-laravel.com/en/docs/3.x/model-resource/buttons#delete

protected function modifyDeleteButton(ActionButtonContract $button): ActionButtonContract
{
    return $button->canSee(fn($data) => true|false);
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by WillieOng-HK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants