/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $authObj = new AuthGroup(); $data = $request->all(); $validator = $authObj->operationValidation(); unset($data['_token']); if ($validator->fails()) { return redirect()->back()->withErrors($validator->messages())->with($data); } try { DB::transaction(function () use($id, $data) { AuthGroupRelaionship::deleteAuthGroupRelationshipGroupLabel($id); AuthGroupRelaionship::saveAddAuthGroupRelationship($data['group_label'], $data['auth']); AuthGroup::find($id)->update($data); }); return redirect()->action('Admin\\AuthGroupController@index')->with(array('dialog' => array('title' => '修改权限组成功', 'message' => $data))); } catch (\Exception $e) { return redirect()->back()->withErrors(['error' => '修改权限组失败, 请重试'])->with($data); } }