Esempio n. 1
0
 /**
  * Extend update validations.
  *
  * @param  \Illuminate\Contracts\Validation\Validator  $validator
  *
  * @return void
  */
 protected function extendUpdate(ValidatorResolver $validator)
 {
     $name = Keyword::make($validator->getData()['name']);
     $validator->after(function (ValidatorResolver $v) use($name) {
         if ($this->isRoleNameGuest($name)) {
             $v->errors()->add('name', trans('orchestra/control::response.roles.reserved-word'));
         }
     });
 }
Esempio n. 2
0
 /**
  * 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);
 }
Esempio n. 3
0
 /**
  * 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];
 }