/** * Update the specified Gyms in storage. * @param int $id * @param UpdateGymsRequest $request * @return Response */ public function update($id, UpdateGymsRequest $request) { $gyms = $this->gymsRepository->find($id); if (empty($gyms)) { Flash::error('Gyms not found'); return redirect(route('gyms.index')); } $logotipoAtual = $gyms->logotipo; $logotipoNovo = $request->logotipo; $gyms = $this->gymsRepository->updateRich($request->all(), $id); if ($logotipoNovo) { if ($logotipoAtual) { if (\File::exists(base_path() . '/public/images/' . $logotipoAtual)) { \File::Delete(base_path() . '/public/images/' . $logotipoAtual); } } $name = Input::file('logotipo')->getClientOriginalName(); Image::make(Input::file('logotipo'))->save(base_path() . '/public/images/' . $name); $gym = \App\Gym::find($id); $gym->logotipo = $name; $gym->save(); } Flash::success('Gyms updated successfully.'); return redirect(route('gyms.index')); }