validated()); $this->storeUploadedImage($request, $subrange, 'picture'); $subrange->saveOrFail(); return redirect()->route('bo.ranges.index'); } public function edit(SubRange $subrange) { return view('bo.subranges.edit', ['subrange' => $subrange]); } public function update(UpdateSubRange $request, SubRange $subrange) { $subrange->fill($request->validated()); $this->storeUploadedImage($request, $subrange, 'picture'); $subrange->saveOrFail(); return redirect()->route('bo.subranges.edit', $subrange) ->with('success', 'Enregistré !'); } public function destroy(SubRange $subrange) { if (File::exists($subrange->picture)) { File::delete($subrange->picture); } if (!$subrange->delete()) { return redirect()->route('bo.ranges.index') ->with('error', 'Le contenu n\'a pas pu être supprimé'); } return redirect()->route('bo.ranges.index') ->with('warning', 'Le contenu a bien été supprimé'); } }