I am working on a project for my self and was wondering if there is a good solution for the following problem.
At the moment I am creating a user > role > permission system. The idea is that when you're creating or updating a role, you can see all the permissions and use checkboxes to add te permission (Really simple). But I want to add more checkboxes for Create, Read, Update and Delete (CRUD).
The setup at this moment is as follows:
Role table: string name
Permission table: string name
PermissionRole table: uint role_id, uint permission_id, boolean create, boolean read, boolean update, boolean delete
To add the permissions to the role I am using the sync() method.
Example:
$role->permissions()->sync([1 => ['create' => 1, 'update' => 1], 2 => ['create' => 1]]);
And this works fine. But, when I am updating instead of inserting and for example I uncheck the checkbox create by the first permission the create won't be set to false, because the form doesn't send the create checkbox anymore.
Is there a way to use the sync method and let it set the not added fields to false by default?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2lfmeSB
via IFTTT
Aucun commentaire:
Enregistrer un commentaire