Exemplo n.º 1
0
 /**
  * @param integer $id
  * @return UserRole
  * @throws HttpResponseException
  */
 protected function getRole($id)
 {
     try {
         return UserRole::findOrFail($id);
     } catch (ModelNotFoundException $e) {
         $this->throwFailException($this->smartRedirect()->withErrors(trans('users::role.messages.not_found')));
     }
 }
Exemplo n.º 2
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param integer $id
  * @param  array $data
  * @return User
  */
 public function update($id, array $data)
 {
     $role = UserRole::findOrFail($id);
     $role->update(array_only($data, ['name', 'description']));
     if ($role->id > 2 and isset($data['permissions'])) {
         $permissions = (array) $data['permissions'];
         $role->attachPermissions($permissions);
     }
     return $role;
 }