Esempio n. 1
0
 /**
  * Eloquent 'deleting' event method.
  *
  * @param  \Arcanedev\LaravelAuth\Models\User|User  $user
  *
  * @return bool
  */
 public function deleting(User $user)
 {
     if ($user->isAdmin()) {
         return false;
     }
     if ($user->isForceDeleting()) {
         $user->roles()->detach();
     }
     $this->event->fire('auth.users.deleting', compact('user'));
     return true;
 }
Esempio n. 2
0
 /**
  * Check the user is allowed to see this item.
  *
  * @return bool
  */
 public function allowed()
 {
     if ($this->user->isAdmin()) {
         return true;
     }
     if (empty($this->roles) && empty($this->permissions)) {
         return true;
     }
     foreach ($this->roles as $roleSlug) {
         if ($this->user->hasRoleSlug($roleSlug)) {
             return true;
         }
     }
     foreach ($this->permissions as $permissionSlug) {
         if ($this->user->may($permissionSlug)) {
             return true;
         }
     }
     return false;
 }
Esempio n. 3
0
 /**
  * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
  * @param  mixed                                   $ability
  *
  * @return bool
  */
 public function before(User $user, $ability)
 {
     if ($user->isAdmin()) {
         return true;
     }
 }
Esempio n. 4
0
 /**
  * Check if the user is allowed.
  *
  * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
  *
  * @return bool
  */
 private function isAllowed($user)
 {
     return $user->isAdmin() || $user->isModerator();
 }