laravel-acl
laravel-acl copied to clipboard
slug in permission function
hi, i use entrust before to control acl in laravel when my project is still laravel 4, and now with laravel 5.2 entrust no longer work, especialy in route filtering...
and then i find this package and trying to use it.. but still got a lot of question, so to make it more simple i will explain my use case when i use entrust: first i want to make a permission for create, view, update and delete for article, in entrust i will create permission like create_article, view_article, update_article and delete_article. But now in kodeine when i create permission there is "slug" so i tried to do this like in documentation say
$permUser = $permission->create([
'name' => 'article',
'slug' => [ // pass an array of permissions.
'create' => true,
'view' => true,
'update' => true,
'delete' => true
],
'description' => 'Manange article'
]);
so from what i read it will be just grouping all of my article permission into one place and there is slug with each parameters view,create,update,delete
the problem i see is, if i want to make my users to only can view article... how to do that based on permission that i created up there?
since from documentation the to assignPermission is only give permission name and that mean it will include all slug in there and it will be all true?
so if i want to make users only can view article i need to create something like
$permUser = $permission->create([
'name' => 'article',
'slug' => [ // pass an array of permissions.
'view' => true,
],
'description' => 'view article'
]);
and if i want to make users only can create article then i will mean i need to create
$permUser = $permission->create([
'name' => 'article',
'slug' => [ // pass an array of permissions.
'create' => true,
],
'description' => 'create article'
]);
then whats the point of slug?
I have a very similar use case in my application. I suggest you to keep all your article permissions as you alredy have it, in one big group but all of them set to false. You can create a "child" group permission for your users role using Inheritance, setting to true all of those permissions your users need. You can then asign that child group to your users role (not the big one) and the user role tou your specific user.
well i already find my a way to make it works like what i want it to be... you can see the solution i come up with in stackoverflow