You can copy the hasRole method from User model and adapt it to Role Model for permissions.
Role and permission listing
Hi I have now implemented Zizaco/Entrust in order to have effective role and permission enforcement in my application. I want to make table, like they have in Drupal, where I can see which permissions are assigned to each role. It is no problem to create a column for each role and place a checkbox in these columns next to a specific permission. My issue is that I cannot get it to assign a true/false value for each checkbox. If I did just have an array of strings or integers, I could easily use in_array() for this, but it does not work with an array of Eloquent models. Any suggestion for how I can determine ifa specific role has a given permission?
Ended up creating this method
public function permissions()
{
$permissionList = $this->perms;
$output = array();
foreach ($permissionList as $permission)
{
$output[] = $permission->id;
}
return $output;
}
Now it returns an array of permission_id's which I can then compare the ID of the current permission using in_array().
Please or to participate in this conversation.