Search code examples
phplaravellaravel-permission

How can i assign user-list permission to other roles also in laravel for spatie package(ACL Management)?


I am using Spatie package for ACL Management in Laravel and its working perfectly but i want to ask one question.If i have to assign user-list permission to any role like Manager even it has permission then it generates an error. and what is the purpose of 'only' attribute below in constructor and 'permission:role-list' doesn't assign any function, is there any default behavior?

function __construct()
{
    $this->middleware('permission:role-list');
    $this->middleware('permission:role-create', ['only' => ['create','store']]);
    $this->middleware('permission:role-edit', ['only' => ['edit','update']]);
    $this->middleware('permission:role-delete', ['only' => ['destroy']]);
}

should i assume if i have to access any function of role controller than it must have role-list permission in Spatie.

Please guide me if i am thinking wrong.


Solution

  • i am telling answer to my own question, in constructor if i have first method without any permission assign to method below.

     $this->middleware('permission:role-list');
    

    so if any role doesn't have this permission it generate an error the role doesn't have permission for this and it does not check next permission.