public function postGroupList(Request $request) { //新增职务 if ($request->has('new_cp_group_name')) { $new_cp_group_name = $request->input('new_cp_group_name'); if (in_array($new_cp_group_name, array('系统管理员', '超级管理员')) || AdminGroup::where('cp_group_name', '=', $new_cp_group_name)->first()) { return redirect($this->redirectPath('/user/groups'))->withErrors([Lang::get('access.addNewCpGroupFailed')]); } $adminGroup = new AdminGroup(); $adminGroup->cp_group_name = strip_tags($new_cp_group_name); $adminGroup->save(); } //更新职务 if ($request->has('name')) { foreach ($request->input('name') as $cp_group_id => $cp_group_name) { $adminGroup = AdminGroup::find($cp_group_id); $adminGroup->cp_group_name = $cp_group_name; $adminGroup->save(); } } //删除职务 if ($request->has('delete')) { AdminAccess::destroy($request->input('delete')); User::whereIn('cp_group_id', $request->input('delete'))->delete(); AdminGroup::destroy($request->input('delete')); } return redirect($this->redirectPath('/user/groups'))->with($this->statusVar, Lang::get('access.updateCpGroupSuccess')); }