예제 #1
0
 /**
  * Determines whether the user has local access to the
  * permission with the given ID.
  *
  * @param $permission
  * @param $id
  * @return bool
  */
 private function hasLocalAccess($permission, $id)
 {
     if (!$id) {
         return false;
     }
     $permission = Permission::where('name', $permission);
     if ($permission->count() == 0 || $permission->first()->table == null) {
         return false;
     }
     if (DB::table($permission->first()->table)->where($permission->first()->user_id_column, Auth::id())->where($permission->first()->foreign_id_column, $id)->where('is_privileged', true)->count() > 0) {
         return true;
     }
     return false;
 }
예제 #2
0
 /**
  * Delete a single permission.
  *
  * @param $id
  */
 public function destroy($id)
 {
     Permission::findOrFail($id)->delete();
 }
예제 #3
0
파일: Role.php 프로젝트: emilmoe/guardian
 /**
  * Remove permission from role.
  *
  * If user doesn't have same client id or role is locked,
  * the action will be prevented.
  *
  * @param string $permission
  */
 public function removePermission($permission)
 {
     if ($this->locked == true) {
         return;
     }
     if (Guardian::hasClients()) {
         if (Guardian::getClientId() != $this->{Guardian::getClientColumn()}) {
             return;
         }
     }
     $id = Permission::where('name', $permission)->first()->id;
     $this->permissions()->detach($id);
 }