/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $object = UserType::find($id); if ($object) { $params = $request->only('name', 'phone', 'email', 'type_id'); $filter = $object->validator($params, ['email' => 'required|email|unique:users,email,' . $id]); if ($filter->fails()) { $error = $filter->errors()->toArray(); $params['id'] = $id; return view('admin.trader.edit', ['input' => $params, 'error' => $error, 'options' => Option::where('user_id', $id)->get(), 'districts' => District::all(), 'brands' => Brand::all(), 'types' => UserType::all()]); } $object->fill($params); $object->save(); return redirect('admin/trader/' . $id . '/edit'); } if ($request->ajax()) { return $this->responseAnswer(false, null, null, trans('user.badUser')); } else { return redirect('admin/traders'); } }