/** * 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; }
/** * 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; }
/** * @param \Arcanesoft\Contracts\Auth\Models\User $user * @param mixed $ability * * @return bool */ public function before(User $user, $ability) { if ($user->isAdmin()) { return true; } }
/** * Check if the user is allowed. * * @param \Arcanesoft\Contracts\Auth\Models\User $user * * @return bool */ private function isAllowed($user) { return $user->isAdmin() || $user->isModerator(); }