コード例 #1
0
ファイル: HasRoles.php プロジェクト: thosoft/authorization
 /**
  * @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
ファイル: Repository.php プロジェクト: techexim/authorization
 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;
 }