I'm currently trying to figure out how to get the permissions for a role with Laravel and Entrust. It uses a pivot table called permission_role
that has the role_id
and permission_id
stored in it.
What I'm trying to do is get the role with it's ID and then get the permissions associated with that role. I think I may be over complicating it, but since I have had zero luck on it I was hoping someone could help me out.
You may try this:
// Hope you have something like this:
class Role extends EntrustRole {}
Then get all permissions from the role whose id
is 1
:
$role = Role::with('perms')->find(1); // Assumed 1 is role id
dd($role->perms); // all permissions in the role
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.