Inheritance: extends Repository
 /**
  * 删除
  *
  * @param ineger $id 公众号iD
  */
 public function getDestroy($id)
 {
     $role = $this->roleRepository->getById($id);
     if ($role->user) {
         return responseFail('该角色下存在用户不能删除');
     }
     $this->roleRepository->destroy($id);
     return responseSuccess('删除成功');
 }
 /**
  * @param Request $request
  *
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function store(Request $request)
 {
     $input = $request->all();
     $roles = $this->role->all();
     $levelMaxLoggedUser = $this->auth->user()->getLevelMax();
     foreach ($roles as $role) {
         if ($role->level <= $levelMaxLoggedUser) {
             $permissions_sync = isset($input['roles'][$role->id]) ? $input['roles'][$role->id]['permissions'] : [];
             $role->perms()->sync($permissions_sync);
         }
     }
     Flash::success('Permissions successfully updated');
     return redirect('/role_permission');
 }
示例#3
0
 /**
  * Remove the specified Role from storage.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     $this->authorize('system.manage');
     $role = $this->roleRepository->findWithoutFail($id);
     if (empty($role)) {
         Flash::error('Role not found');
         return redirect(route('roles.index'));
     }
     $this->roleRepository->delete($id);
     Flash::success('Role deleted successfully.');
     return redirect(route('roles.index'));
 }
 /**
  * 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->isRoot()) {
         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();
     $themes = \Theme::getList();
     $themes = Arr::indexToAssoc($themes, true);
     $theme = $att['theme'];
     $time_zones = \DateTimeZone::listIdentifiers();
     $tzKey = $att['time_zone'];
     $time_format = $att['time_format'];
     $locales = Setting::get('app.supportedLocales');
     $locale = $att['locale'];
     return view('admin.users.edit', compact('user', 'roles', 'perms', 'themes', 'theme', 'time_zones', 'tzKey', 'time_format', 'locale', 'locales', 'page_title', 'page_description'));
 }
 /**
  * @return \Illuminate\View\View
  */
 public function disableSelected(Request $request)
 {
     //TODO: Should we protect 'admins', 'users'??
     $chkRoles = $request->input('chkRole');
     if (isset($chkRoles)) {
         foreach ($chkRoles as $role_id) {
             $role = $this->role->find($role_id);
             $role->enabled = false;
             $role->save();
         }
         Flash::success(trans('admin/roles/general.status.global-disabled'));
     } else {
         Flash::warning(trans('admin/roles/general.status.no-role-selected'));
     }
     return redirect('/admin/roles');
 }
 /**
  * @param $id
  *
  * @return \Illuminate\View\View
  */
 public function edit($id)
 {
     $user = $this->user->find($id);
     $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);
     }
     $roles = $this->role->all();
     $perms = $this->perm->all();
     //        $roleCollection = \App\Models\Role::take(10)->get(['id', 'display_name'])->lists('display_name', 'id');
     //        $roleList = [''=>''] + $roleCollection->all();
     return view('admin.users.edit', compact('user', 'roles', 'perms', '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']);
     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'));
 }
示例#8
0
 /**
  * Update roles
  *
  * @param  App\requests\RoleRequest $request
  * @return Response
  */
 public function postRoles(RoleRequest $request)
 {
     $this->role_gestion->update($request->except('_token'));
     return redirect('user/roles')->with('ok', trans('back/roles.ok'));
 }
 /**
  * @param Request $request
  * @return mixed
  */
 public function getInfo(Request $request)
 {
     $id = $request->input('id');
     $role = $this->role->find($id);
     return $role;
 }
示例#10
0
 public function createRoles()
 {
     return view('back.users.roles_create', $this->role_gestion->getAllSelect());
 }
示例#11
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param User $user
  * @return Response
  * @internal param int $id
  */
 public function edit(User $user)
 {
     $roles = $this->role->lists('name', 'id');
     return view('admin.users.edit', compact('user', 'roles'));
 }