public function allow($nameOrId)
{
foreach ($this->roles as $role) {
// See if role has all permissions
if ($role->all) {
return true;
}
// Validate against the Permission table
foreach ($role->permissions as $perm) {
// First check to see if it's an ID
if (is_numeric($nameOrId)) {
if ($perm->id == $nameOrId) {
return true;
}
}
// Otherwise check by name
if ($perm->name == $nameOrId) {
return true;
}
}
}
return false;
}