示例#1
0
 /**
  * @param RoleContract $role
  * @return bool
  */
 public function hasRole(RoleContract $role)
 {
     foreach ($this->getRoles() as $objectRole) {
         if ($objectRole instanceof RoleContract && $objectRole->getId() === $role->getId()) {
             return true;
         }
     }
     return false;
 }
示例#2
0
 public function hasObjectRole(ItemContract $subject, RoleContract $role, ItemContract $object)
 {
     // TODO: Implement hasObjectRole() method.
     return Object::where('subject_type', $subject->getType())->where('subject_id', $subject->getId())->where('object_type', $object->getType())->where('object_id', $object->getId())->where('role_id', $role->getId())->first() ? true : false;
 }