Exemple #1
0
 public function getRole(ActionInterface $action)
 {
     $role = null;
     foreach ($this->roleRepository->all() as $repositoryRole) {
         if ($repositoryRole->getName() == "Superuser") {
             $role = $repositoryRole;
         }
     }
     if ($role === null) {
         $role = $this->roleRepository->create();
         $role->setName('Superuser');
         if ($this->roleRepository->save($role) == false) {
             $role = null;
         }
         $role->addPermission($action, 1);
     }
     return $role;
 }
Exemple #2
0
 /**
  * Remove the specified role from storage.
  *
  * @param RoleInterface $role
  * @internal param int $id
  * @return Response
  */
 public function destroy(RoleInterface $role)
 {
     $response = null;
     $user = $this->getUser();
     if ($user->can('delete', $role)) {
         if ($this->role_repository->delete($role)) {
             $response = Redirect::route('roles.role.index')->with('success', trans('roles::role.delete_success'));
         } else {
             $response = Redirect::back()->withErrors($this->role_repository->getErrors());
         }
     } else {
         $response = Redirect::home();
     }
     return $response;
 }