i have 2 roles writer and admin.
writer role has permission to create article, edit article, delete article
how can I remove the create article permission for a specified user without removing removing it from the writer role ?
i have 2 roles writer and admin.
writer role has permission to create article, edit article, delete article
how can I remove the create article permission for a specified user without removing removing it from the writer role ?
2
Answers
Roles and permissions are not necessarily the same thing. In the Spatie library you mentioned, you can use roles to group different permissions to make it easier for you to manage them.
So instead of you assigning different permissions to every single user like "can-create-post," "can-edit-post," etc., you create a role, for example, "publisher," and assign the permissions to that role, then assign the role to the user you want.
If I were you, I would create the "Writer" role like you mentioned, assign it the RUD (read, update, delete) permissions, and assign that role to the users who should have that ability. On top of that, in the admin panel, I would have a checkbox or something similar where the admin can tick "Can create article." If it’s ticked, on the backend, what would be called is:
If not, then it would be just the
And if you ever wanted to edit a user and remove his ability to create posts, you would open hi profile in the admin panel and untick the checkbox which would call the
Hope this was of help 🙂
A permission can be revoked from a user:
you can checkout the documentation of Spatie for more information about Direct Permissions