/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $partner = partner::findOrFail($id); $partner->title_geo = $request->input('title_geo'); $partner->title_eng = $request->input('title_eng'); $partner->title_rus = $request->input('title_rus'); $partner->url = $request->input('url'); $partner->content_geo = $request->input('content_geo'); $partner->content_eng = $request->input('content_eng'); $partner->content_rus = $request->input('content_rus'); if (NULL !== $request->file('image')) { File::delete(public_path() . '/uploads/partner/' . $partner->image); $image = $request->file('image'); $fileName = ""; if ($image->isValid()) { $path = public_path() . '/uploads/partner/'; $fileName = str_random(32) . '.' . $image->getClientOriginalExtension(); $image->move($path, $fileName); } $partner->image = $fileName; } $partner->save(); return Redirect::route('admin.partner.show'); }