/** * Verify whether current user has sufficient roles to access the * actions based on available type of access if the action exist. * * @param string $action A string of action name * * @return bool */ public function canIf($action) { $roles = $this->getUserRoles(); $action = Keyword::make($action); if (is_null($this->actions->search($action))) { return false; } return $this->checkAuthorization($roles, $action); }
/** * Check if role name is "guest". * * @param \Orchestra\Support\Keyword $name * * @return bool */ protected function isRoleNameGuest(Keyword $name) { return $name->searchIn(['guest']) !== false; }
/** * Get keyword instance. * * @return \Orchestra\Support\Keyword */ protected function getKeyword($key) { if ($key instanceof Keyword) { return $key; } if (!isset($this->cachedKeyword[$key])) { $this->cachedKeyword[$key] = Keyword::make($key); } return $this->cachedKeyword[$key]; }