/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { if (\Auth::user()->roles[0]->can('menu-delete')) { $this->menus->findOrFail($id)->delete(); return \Redirect::route('admin.menus.index', [])->withMessage(trans('acl::menu.menus-controller-successfully_deleted')); } return \Redirect::route('admin.menus.index')->withErrors(trans('acl::dashboard.unauthorized_access')); }
public static function getroleemail($userid) { $role_id = User::where('id', $userid)->value('role_id'); $role = Role::findOrFail($role_id); $chucnang = 'thuden'; $rolechucnangs = RoleChucnang::join('danhmucchucnangs', 'role_chucnangs.danhmucchucnang_id', '=', 'danhmucchucnangs.id')->where('role_id', $role->id)->where('danhmucchucnangs.chucnang_id', $chucnang)->select('danhmucchucnangs.id', 'role_chucnangs.role_id', 'role_chucnangs.danhmucchucnang_id', 'role_chucnangs.Danhsach', 'role_chucnangs.Xem', 'role_chucnangs.Them', 'role_chucnangs.Sua', 'role_chucnangs.Xoa', 'danhmucchucnangs.tenchucnang', 'danhmucchucnangs.chucnang_id', 'danhmucchucnangs.orders', 'danhmucchucnangs.level')->first(); return $rolechucnangs; }
/** * Update the specified resource in storage. * * @param int $id * @param \Illuminate\Http\Request $request * * @return void */ public function update($id, Request $request) { $this->validate($request, ['name' => 'required']); $role = Role::findOrFail($id); $role->update($request->all()); Session::flash('flash_message', 'Role updated!'); return redirect('admin/roles'); }
/** * Update the specified resource in storage. * * @param \App\Http\Requests\EditRoleRequest $request * @param int $id * @return \Illuminate\Http\Response */ public function update(EditRoleRequest $request, $id) { $this->authorize('roles-edit'); $role = Role::findOrFail($id); $role->update($request->all()); $permissions = empty($request->permissions) ? [] : $request->permissions; $role->permissions()->sync($permissions); return redirect('roles'); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(Request $request, $id) { $this->validate($request, ['name' => 'required|unique:roles,id,' . $id . '|max:255', 'label' => 'required|unique:roles,id,' . $id . '|max:255']); $role = Role::findOrFail($id); $role->update($request->all()); $this->syncPermissions($role, $request->input('permission_list')); flash()->success('Success!', 'Role has been updated!'); return redirect('roles'); }
public function updateRole($id, Request $request) { $role = Role::findOrFail($id); $permission_id = $request->permission_id ? $request->permission_id : []; $role->permissions()->sync($permission_id); flash()->message('修改成功!'); return redirect()->back(); // return redirect('admin/users/roles'); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(Request $request, $id) { if (!$this->user->userCan('role-edit')) { \App::abort(403, 'Access denied'); } $role_model = \App\Role::findOrFail($id); $role_model->update($request->all()); $role_model->permissions()->sync($request->get('permissions', [])); return redirect('/admin/role'); }
public function destroy($roleId) { try { $role = Role::findOrFail($roleId); $role->delete(); } catch (Exception $e) { Session::flash('message', 'Fail : ' . $e->getMessage()); } return Redirect::back(); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(RoleRequest $request, $id) { // $role = Role::findOrFail($id); $role->name = $request->input('name'); $role->display_name = $request->input('display_name'); $role->description = $request->input('description'); $role->update(); return redirect('system/roles'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $role = Role::findOrFail($id); $this->validate($request, ['name' => 'required|max:255', 'label' => 'required|max:255']); $input = $request->all(); $role->label = $request->label; $role->name = $request->name; $role->save(); Session::flash('flash_message', 'Role updated!'); return redirect()->back(); }
protected function rolechucnangs($chucnang) { $userid = Auth::user()->id; //Cookie::make('userfolder', Auth::user()->username); Cookie::queue(Cookie::make('userfolder', Auth::user()->username, 5)); $role_id = User::where('id', $userid)->value('role_id'); $role = Role::findOrFail($role_id); $this->menus = $role->danhmuchucnangs()->orderBy('orders')->orderBy('tenchucnang')->get(); $rolechucnangs = RoleChucnang::join('danhmucchucnangs', 'role_chucnangs.danhmucchucnang_id', '=', 'danhmucchucnangs.id')->where('role_id', $role->id)->where('danhmucchucnangs.chucnang_id', $chucnang)->select('danhmucchucnangs.id', 'role_chucnangs.role_id', 'role_chucnangs.danhmucchucnang_id', 'role_chucnangs.Danhsach', 'role_chucnangs.Xem', 'role_chucnangs.Them', 'role_chucnangs.Sua', 'role_chucnangs.Xoa', 'danhmucchucnangs.tenchucnang', 'danhmucchucnangs.chucnang_id', 'danhmucchucnangs.orders', 'danhmucchucnangs.level')->first(); return $rolechucnangs; }
public function postDelete(Request $request) { $role = Role::findOrFail($request->get('id')); $arr = array('id' => $role->id, 'name' => $role->name); if ($role->delete()) { $message = trans('language.ROLE-DELETED'); // Logging::deleted('Role', $arr); } else { $message = trans('language.ROLE-NOT-DELETED'); // Logging::not_deleted('Role', $arr); } return redirect()->route('admin-roles-list')->with('global', $message); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(Request $request, $id) { $user = User::findOrFail($id); $role = Role::findOrFail(Input::get('role')); if (!$user->hasRole($role->name)) { $user->detachRoles($user->roles); $user->attachRole($role); Notification::success('Al usuario <strong>' . $user->name . '</strong> se le asigno el rol <strong>' . $role->display_name . '</strong>'); return redirect('roles'); } else { return redirect('roles'); } }
public function update($id, Request $request) { Laralum::permissionToAccess('laralum.roles.access'); # Check permissions Laralum::permissionToAccess('laralum.roles.edit'); # Find the row $row = Role::findOrFail($id); if (!$row->allow_editing and !Laralum::loggedInuser()->su) { abort(403, trans('laralum.error_editing_disabled')); } # Save the data $data_index = 'roles'; require 'Data/Edit/Save.php'; # Return the admin to the users page with a success message return redirect()->route('Laralum::roles')->with('success', trans('laralum.msg_role_edited')); }
/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { switch ($this->method()) { case 'GET': case 'DELETE': return []; case 'POST': return ['name' => 'required|min:3|max:255|unique:roles,name']; case 'PUT': case 'PATCH': $id = $this->route()->roles; $role = Role::findOrFail($id); return ['name' => 'required|min:3|max:255|unique:roles,name,' . $role->id]; default: break; } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { if (Auth::check() && $this->rolechucnangs && $this->rolechucnangs->Xoa == 1) { $role = Role::findOrFail($id); $role->delete(); return \Redirect::route('role.index')->with('message', 'Xóa Thành Công!'); } else { return \Redirect::route('role.index')->with('message-error', 'Không có quyền truy cập'); } }
/** * @Given the permission with the id :arg1 has the role with the id :arg2 */ public function thePermissionWithTheIdHasTheRoleWithTheId($arg1, $arg2) { $permission = Permission::findOrFail($arg1); $role = Role::findOrFail($arg2); $permission->addRole($role); }
/** * Update the specified resource in storage. * * @param int $id * * @return Response */ public function update($id, Request $request) { $this->validate($request, ['name' => 'required', 'display_name' => 'required']); $role = Role::findOrFail($id); $role->update($request->all()); if ($role->permissions->count()) { $role->permissions()->detach($role->permissions()->lists('permission_id')->toArray()); } $role->attachPermissions($request->input('permission_id')); Session::flash('flash_message', 'Role updated!'); return redirect('admin/roles'); }
public function edit($id) { $role = Role::findOrFail($id); return view('admin.role.edit', compact('role')); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\RedirectRespons */ public function destroy($id) { $user = $this->users->findOrFail($id); User::destroy($id); return \Redirect::route('admin.users.index', [])->withMessage(trans('acl::user.users-controller-successfully_deleted')); }
/** * 权限保存 * * @param int $id * @return Response */ public function storePermission(Request $request, $id) { $role = Role::findOrFail($id); $role->permissions()->sync($request->get('permissions', [])); $this->alert('配置权限成功'); return redirect(route('role.editPermission', $role->id)); }
/** * Remove the specified resource from storage. * * @param RoleRequest $request * @param $roleId * @return \Illuminate\Http\JsonResponse */ public function destroy(RoleRequest $request, $roleId) { Role::findOrFail($roleId)->delete(); return $this->response->noContent(); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\RedirectResponse */ public function destroy($id) { $this->roles->findOrFail($id)->delete(); return \Redirect::route('admin.roles.index', [])->withMessage(trans('acl::role.roles-controller-successfully_deleted')); }
public function updaterole(Request $request, $id) { $user = User::findOrFail($id); $role = Role::findOrFail($request->input('role_id')); if ($role != null) { if (!$user->hasRole($role->name)) { $user->attachRole($role); } } return redirect('system/users'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { Role::findOrFail($id)->delete(); return trans('groups.removed'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(RolesRequest $request, $id) { $module_name = $this->module_name; $module_name_singular = str_singular($this->module_name); ${$module_name_singular} = Role::findOrFail($id); ${$module_name_singular}->update($request->except('permissions_list')); if ($request->input('permissions_list') === null) { $permissions = array(); ${$module_name_singular}->permissions()->sync($permissions); } else { ${$module_name_singular}->permissions()->sync($request->input('permissions_list')); } return redirect("admin/{$module_name}")->with('flash_success', "Update successful!"); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($roleId, $permissionId) { // $role = Role::findOrFail($roleId); $permission = Permission::findOrFail($permissionId); if ($role != null && $permission != null) { $role->detachPermission($permission); } else { back(); } return redirect('system/roles/' . $roleId . '/permissions'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $user = User::findOrFail($id); $this->validate($request, ['name' => 'required', 'username' => 'required|unique:users,username,' . $id, 'email' => 'required|email|unique:users,email,' . $id, 'role' => 'required|integer|min:1']); $role = Role::findOrFail($request->role); $user->name = strtoupper($request->name); $user->username = $request->username; $user->email = $request->email; $user->active = $request->status; $user->update(); $user->detachRoles($user->roles); $user->roles()->attach($role); Session::flash('flash_message', 'User successfully updated.'); Session::flash('flash_class', 'alert-success'); return redirect()->route("store_user.index"); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function delete($id) { $role = Role::findOrFail($id); $role->delete(); }
public function detatchUser($user, $role, User $users, Role $roles) { $user = $users->findOrFail($user); if (auth()->user()->id == $user->id) { return redirect()->back()->withDanger("Detaching your own user is not allowed. This needs to be done manually, contact admin..."); } $role = $roles->findOrFail($role); $user->role_id = null; $user->save(); return redirect()->route('admin.roles.index')->withSuccess("User {$user->name} no longer has the role {$role->role}."); }