Example #1
0
 /**
  * Compose the view.
  *
  * @param  \Illuminate\Contracts\View\View  $view
  */
 public function composeFilters(View $view)
 {
     $filters = new Collection();
     $roles = $this->cacheResults('roles.filters', function () {
         return $this->role->has('users')->get();
     });
     foreach ($roles as $role) {
         /** @var  \Arcanesoft\Auth\Models\Role  $role */
         $filters->put($role->slug, link_to_route('admin::auth.users.roles-filter.index', $role->name, [$role->hashed_id]));
     }
     $view->with('rolesFilters', $filters);
 }
Example #2
0
 public function composeFilters(View $view)
 {
     $filters = collect();
     $roles = Cache::remember('cache::auth.roles.filters', 1, function () {
         return $this->role->has('users')->get();
     });
     foreach ($roles as $role) {
         /** @var  \Arcanesoft\Contracts\Auth\Models\Role  $role */
         $filters->put($role->slug, link_to_route('auth::foundation.users.roles-filter.index', $role->name, [$role->hashed_id]));
     }
     $view->with('rolesFilters', $filters->toArray());
 }
Example #3
0
 /**
  * Eloquent 'deleting' event method.
  *
  * @param  \Arcanedev\LaravelAuth\Models\Role|Role  $role
  */
 public function deleting(Role $role)
 {
     $role->users()->detach();
     $role->permissions()->detach();
     $this->event->fire('auth.roles.deleting', compact('role'));
 }
Example #4
0
 /**
  * Show the edit the user form.
  *
  * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
  * @param  \Arcanesoft\Contracts\Auth\Models\Role  $role
  *
  * @return \Illuminate\View\View
  */
 public function edit(User $user, Role $role)
 {
     $this->authorize(UsersPolicy::PERMISSION_UPDATE);
     $user->load(['roles', 'roles.permissions']);
     $roles = $role->all();
     $title = 'Edit a user';
     $this->setTitle($title);
     $this->addBreadcrumb($title);
     return $this->view('foundation.users.edit', compact('user', 'roles'));
 }
Example #5
0
 public function delete(Role $role)
 {
     /** @var  \Arcanesoft\Auth\Models\Role  $role */
     self::onlyAjax();
     $this->authorize(RolesPolicy::PERMISSION_DELETE);
     try {
         $role->delete();
         $message = "The role {$role->name} has been successfully deleted !";
         Log::info($message, $role->toArray());
         $this->notifySuccess($message, 'Role deleted !');
         $ajax = ['status' => 'success', 'message' => $message];
     } catch (\Exception $e) {
         $ajax = ['status' => 'error', 'message' => $e->getMessage()];
     }
     return response()->json($ajax);
 }