public function postEdit(AdminUserRequest $request) { $user = AdminUser::find($request->id); if (!$user) { return $this->notfound(); } $user->username = $request->telephone; $user->telephone = $user->username; $is_user = $user->where('username', $user->telephone)->where('id', '!=', $user->id); if ($is_user->count() > 0) { return response('手机号码已存在', 422); } $user->email = $user->username . "@" . env("DOMAIN", "admin5.cc"); $user->truename = $request->truename; if ($request->password != "") { $user->password = bcrypt($request->password); } $user->confirmed = $request->confirm ? 1 : 0; $user->save(); if ($user->id) { $user->saveRoles($request->roles); return response(saveok()); } else { return response("操作失败", 422); } }
public function postEdit(AdminMenuRequest $request) { $menu = new AdminMenu(); if ($request->has('id')) { $menu = $menu->find(request('id')); if (!$menu) { return response('找不到相关记录', 422); } } else { return response('找不到相关记录', 422); } $menu->name = $request->name; $menu->parent_id = $request->parent_id; $menu->route = trim($request->route); $menu->action = trim($request->action); $menu->order_by = $request->order_by; if (!$menu->validateParentId()) { return response("上级路由不能选择当前修改路由", 422); } if (!$menu->validateAction()) { return response("当前路由为访问地址时,指向控制器不能为空", 422); } if ($menu->save()) { \Cache::forget("all_routes"); return saveok(); } else { return response('操作失败', 422); } }
public function postEdit(AdminRoleRequest $request) { $this->role = $this->role->find($request->get('id')); if (!$this->role->id) { return response('找不到相关记录', 422); } $this->role->name = $request->get('name'); $this->role->display_name = $request->get('display_name'); $this->role->save(); if ($this->role->id) { $menu_id = $request->get('menu_id'); if (!empty($menu_id)) { $this->role->sync($menu_id); } return saveok(); } else { return response('操作失败', 422); } }
switch (trim($action)) { case "add": case "edit": edit(); break; case "editstep1": editstep1(); break; case "editstep2": editstep2(); break; case "lastsave": lastsave(); break; case "saveok": saveok(); break; case "del": del(); break; case "collectSimple": collectSimple(); break; case "collectVideo": collectVideo(); break; case "copy": copynew(); break; case "delall": delall();
public function postEdit(AdminRouteRequest $request) { $parent_id = $request->get('parent_id'); $action = $request->get('action'); $route_name = $request->get('route_name'); $route = $this->routes->find($request->get('id')); if (!$route) { return response('找不到相关记录', 422); } if ($parent_id != 0) { if (empty($action) && !\Event::hasListeners('router.filter: ' . $route_name)) { return response($route_name . ':路由验证不存在', 422); } if (!empty($action) && !class_exists('App\\Http\\Controllers\\' . $action)) { return response($action . ':控制器不存在', 422); } } else { $route_name = strtolower($route_name); } $route->name = $request->get('name'); $route->action = $action; $route->route_name = $route_name; $route->other_route = $request->get('other_route', ''); $route->parent_id = $parent_id; $route->priority = $request->has('priority') ? $request->get('priority') : ''; if ($route->save()) { \Cache::forget($route->route_name . "_routes"); return saveok(); } else { return response('保存失败', 422); } }