entrust icon indicating copy to clipboard operation
entrust copied to clipboard

Check to see if role has certain permissions

Open Yelldon opened this issue 11 years ago • 5 comments

Hopefully I won't sound too vague in this issue. Is there any possible way to get a true or false value when checking if a permission is attached to a certain role? So far I've been unable to.

The use case is that I'm listing all roles in a table, and then all the permissions, and then showing a check box for each per on each role per permission. I have it setup correctly in blade, the issue I've ran into is that I haven't been able to get the default value of the checkbox.

For users that have roles, I just did something like this in a loop: $user->hasRole($role->name)

But I've been unable to find something similar for permissions (something like hasPerm or something), other than the 'perm' method, but I can't get it to return a true of false value. Is there any possible way to get a true or false value when checking permissions against a role without users?

Yelldon avatar Jun 02 '15 18:06 Yelldon

Just created a pull PR for this issue PR #323. Hopefully it's found useful enough to merge.

Yelldon avatar Jun 10 '15 21:06 Yelldon

Wasn't the ability function enough for this? I imagine that calling it with a single value for the second argument would have done the trick.

cdarken avatar Jun 28 '15 21:06 cdarken

The problem I saw was that ability still only checked against the user. I didn't need to check against the user per say, I needed to get an overview of what permissions exist against just the roles themselves.

Yelldon avatar Jun 30 '15 15:06 Yelldon

Ah, I assumed you had a list of users based on your $user->hasRole($role->name) example

cdarken avatar Jun 30 '15 21:06 cdarken

This issue was merged into the master branch.

Yelldon avatar Aug 07 '15 20:08 Yelldon