In Laravel Entrust, I need to get all the linked permissions of a specific roleId. How can I do that? I see the permission_role table has the roleId and permissionId relation and then the permissions table has the permission data. Say, if I want to get all permissions for the roleId: 2, how can I do that?
What I found:
I understand, I can use the with(perms) like below but it fetches the list of all roles with permissions which I don’t want.
$roles = Role::with('perms')->get();
What I want: Fetch the permission list of a particular roleId that outputs in an array like this:
(
[create-article] => true
[edit-article] => true
[edit-article] => true
)
Where the permission_name is set as key and true set as value since I then use the above array in frontend javascript for checks.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire