/** * 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; }