Inheritance: extends Repository
 /**
  * @return \Illuminate\View\View
  */
 public function index()
 {
     //        //TODO: Warn of any routes in our DB that is not used in the app.
     $page_title = trans('admin/routes/general.page.index.title');
     $page_description = trans('admin/routes/general.page.index.description');
     $routes = $this->route->pushCriteria(new RoutesWithPermissions())->pushCriteria(new RoutesByPathAscending())->pushCriteria(new RoutesByMethodAscending())->paginate(20);
     $perms = $this->permission->all()->lists('display_name', 'id');
     $perms = $perms->toArray(0);
     array_unshift($perms, '');
     return view('admin.routes.index', compact('routes', 'perms', 'page_title', 'page_description'));
 }
 /**
  * @return \Illuminate\View\View
  */
 public function index()
 {
     //        //TODO: Warn of any routes in our DB that is not used in the app.
     Audit::log(Auth::user()->id, trans('admin/routes/general.audit-log.category'), trans('admin/routes/general.audit-log.msg-index'));
     $page_title = trans('admin/routes/general.page.index.title');
     $page_description = trans('admin/routes/general.page.index.description');
     $routes = $this->route->pushCriteria(new RoutesWithPermissions())->pushCriteria(new RoutesByPathAscending())->pushCriteria(new RoutesByMethodAscending())->paginate(20);
     $perms = $this->permission->all()->lists('display_name', 'id');
     // SR [2016-03-20] Cannot add/prepend a blank item as it reshuffles the array index.
     // This cause the permission to not be recognized by the code building the view and
     // matching permission with each route. From now on un-setting the permission of a
     // few is unsupported by design.
     //        $perms = $perms->toArray(0);
     //        array_unshift($perms, '');
     return view('admin.routes.index', compact('routes', 'perms', 'page_title', 'page_description'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $routeName = 'role';
     $routeMethod = 'edit';
     $role = $this->role->getById($id);
     $permissions = $this->permission->getAllOrderedBy('name');
     $data = compact('routeName', 'routeMethod', 'role', 'permissions');
     \Clockwork::info($permissions);
     return view('admin.sections.role.edit', $data);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(DestroyPermissionRequest $request, $id)
 {
     $result = $this->permission->destroyPermission($id);
     if ($result < 0) {
         return redirect()->back()->with('status', 'destroy-refused');
     }
     if ($result == 0) {
         return redirect()->back()->with('status', 'destroy-error');
     }
     return redirect()->route('admin.permission.index')->with('status', 'destroy-success');
 }
 /**
  * @param $id
  * @return \Illuminate\View\View
  */
 public function edit($id)
 {
     $page_title = trans('admin/roles/general.page.edit.title');
     // "Admin | Role | Edit";
     $page_description = trans('admin/roles/general.page.edit.description');
     // "Editing role";
     $role = $this->role->find($id);
     if (!$role->isEditable() && !$role->canChangePermissions()) {
         abort(403);
     }
     $perms = $this->permission->all();
     $rolePerms = $role->perms();
     return view('admin.roles.edit', compact('role', 'perms', 'rolePerms', 'page_title', 'page_description'));
 }
 /**
  * @param $id
  *
  * @return \Illuminate\View\View
  */
 public function edit($id)
 {
     $role = $this->role->find($id);
     Audit::log(Auth::user()->id, trans('admin/roles/general.audit-log.category'), trans('admin/roles/general.audit-log.msg-edit', ['name' => $role->name]));
     $page_title = trans('admin/roles/general.page.edit.title');
     // "Admin | Role | Edit";
     $page_description = trans('admin/roles/general.page.edit.description', ['name' => $role->name]);
     // "Editing role";
     if (!$role->isEditable() && !$role->canChangePermissions()) {
         abort(403);
     }
     $perms = $this->permission->all();
     return view('admin.roles.edit', compact('role', 'perms', 'page_title', 'page_description'));
 }
 /**
  * @param $id
  * @return \Illuminate\View\View
  */
 public function edit($id)
 {
     $role = $this->role->find($id);
     $page_title = trans('admin/roles/general.page.edit.title');
     // "Admin | Role | Edit";
     $page_description = trans('admin/roles/general.page.edit.description', ['name' => $role->name]);
     // "Editing role";
     if (!$role->isEditable() && !$role->canChangePermissions()) {
         abort(403);
     }
     $perms = $this->permission->all();
     //        $rolePerms = $role->perms();
     //        $userCollection = \App\User::take(10)->get(['id', 'first_name', 'last_name', 'username'])->lists('full_name_and_username', 'id');
     //        $userList = [''=>''] + $userCollection->all();
     return view('admin.roles.edit', compact('role', 'perms', 'page_title', 'page_description'));
 }
 /**
  * @return \Illuminate\View\View
  */
 public function profile()
 {
     $user = Auth::user();
     Audit::log(Auth::user()->id, trans('general.audit-log.category-profile'), trans('general.audit-log.msg-profile-show', ['username' => $user->username]));
     $page_title = trans('general.page.profile.title');
     $page_description = trans('general.page.profile.description', ['full_name' => $user->full_name]);
     $readOnlyIfLDAP = 'ldap' == $user->auth_type ? 'readonly' : '';
     $perms = $this->perm->pushCriteria(new PermissionsByNamesAscending())->all();
     $themes = \Theme::getList();
     $themes = Arr::indexToAssoc($themes, true);
     $theme = $user->settings()->get('theme');
     $time_zones = \DateTimeZone::listIdentifiers();
     $time_zone = $user->settings()->get('time_zone');
     $tzKey = array_search($time_zone, $time_zones);
     $time_format = $user->settings()->get('time_format');
     $locales = Setting::get('app.supportedLocales');
     $locale = $user->settings()->get('locale');
     return view('user.profile', compact('user', 'perms', 'themes', 'theme', 'time_zones', 'tzKey', 'time_format', 'locale', 'locales', 'readOnlyIfLDAP', 'page_title', 'page_description'));
 }
 /**
  * Loads the audit log item from the id passed in, locate the relevant user, then overwrite all current attributes
  * of the user with the values from the audit log data field. Once the user saved, redirect to the edit page,
  * where the operator can inspect and further edit if needed.
  *
  * @param $id
  *
  * @return \Illuminate\View\View
  */
 public function replayEdit($id)
 {
     // Loading the audit in question.
     $audit = $this->audit->find($id);
     // Getting the attributes from the data fields.
     $att = json_decode($audit->data, true);
     // Finding the user to operate on from the id field that was populated in the
     // edit action that created this audit record.
     $user = $this->user->find($att['id']);
     if (null == $user) {
         Flash::warning(trans('admin/users/general.error.user_not_found', ['id' => $att['id']]));
         return \Redirect::route('admin.audit.index');
     }
     Audit::log(Auth::user()->id, trans('admin/users/general.audit-log.category'), trans('admin/users/general.audit-log.msg-replay-edit', ['username' => $user->username]));
     $page_title = trans('admin/users/general.page.edit.title');
     // "Admin | User | Edit";
     $page_description = trans('admin/users/general.page.edit.description', ['full_name' => $user->full_name]);
     // "Editing user";
     if (!$user->isEditable()) {
         abort(403);
     }
     // Setting user attributes with values from audit log to replay the requested action.
     // Password is not replayed.
     $user->first_name = $att['first_name'];
     $user->last_name = $att['last_name'];
     $user->username = $att['username'];
     $user->email = $att['email'];
     $user->enabled = $att['enabled'];
     if (array_key_exists('selected_roles', $att)) {
         $aRoleIDs = explode(",", $att['selected_roles']);
         $user->roles()->sync($aRoleIDs);
     }
     if (array_key_exists('perms', $att)) {
         $user->permissions()->sync($att['perms']);
     }
     $user->save();
     $roles = $this->role->all();
     $perms = $this->perm->all();
     return view('admin.users.edit', compact('user', 'roles', 'perms', 'page_title', 'page_description'));
 }
 /**
  * @return \Illuminate\View\View
  */
 public function index()
 {
     $roles = $this->role->pushCriteria(new RoleLowerOrEqualToCurrentUser($this->auth->user()))->all();
     $permissions = $this->permission->all();
     return view('roles_permissions.index', compact('roles', 'permissions'));
 }