/** * 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; }
/** * Allow to delete a password reset. * * @param \Arcanesoft\Contracts\Auth\Models\User $user * * @return bool */ public function deletePolicy(User $user) { return $user->may(static::PERMISSION_DELETE); }
/** * Allow to delete a category. * * @param \Arcanesoft\Contracts\Auth\Models\User $user * * @return bool */ public function deletePolicy(User $user) { return $user->may('blog.categories.delete'); }
/** * Allow to access all the auth stats. * * @param \Arcanesoft\Contracts\Auth\Models\User $user * * @return bool */ public function statsPolicy(User $user) { return $user->may(static::PERMISSION_STATS); }
/** * Allow to delete a tag. * * @param \Arcanesoft\Contracts\Auth\Models\User $user * * @return bool */ public function deletePolicy(User $user) { return $user->may('blog.tags.delete'); }
/** * Allow to update a role. * * @param \Arcanesoft\Contracts\Auth\Models\User $user * * @return bool */ public function updatePolicy(User $user) { return $user->may(static::PERMISSION_UPDATE); }