validated()); if (is_a($request->picture, "SplFileInfo")) { $pictobrand->picture = Utils::storeImage($request->picture, $pictobrand->getTable()); } if (!$pictobrand->saveOrFail()) { return redirect()->route('bo.pictobrands.edit', $pictobrand->id) ->with('error', 'Le pictogramme n\'a pas été crée'); } return redirect()->route('bo.pictobrands.edit', $pictobrand->id) ->with('success', 'Pictogramme créé !'); } /** * Show the form for editing the specified resource. * * @param PictoBrand $pictobrand * @return \Illuminate\Http\Response * * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ public function edit(PictoBrand $pictobrand) { return view('back.pictobrands.edit', compact('pictobrand')); } /** * Update the specified resource in storage. * * @param PictoBrand $pictobrand * @param \Illuminate\Http\UpdatePictoBrandRequest $request * @return \Illuminate\Http\Response */ public function update(PictoBrand $pictobrand, UpdatePictoBrandRequest $request) { $pictobrand->fill($request->validated()); if (is_a($request->picture, "SplFileInfo")) { $pictobrand->picture = Utils::storeImage($request->picture, $pictobrand->getTable()); } if (!$pictobrand->saveOrFail()) { return redirect()->route('bo.pictobrands.edit', $pictobrand->id) ->with('error', trans('La modification a échoué')); } return redirect()->route('bo.pictobrands.edit', $pictobrand->id) ->with('success', trans('Modifications enregistrées !')); } /** * Remove the specified resource from storage. * * @param PictoBrand $pictobrand * @return \Illuminate\Http\Response */ public function destroy(PictoBrand $pictobrand) { if (!$pictobrand->delete()) { return redirect()->route('bo.pictobrands.index')->with('error', trans('La suppression a échoué')); } return redirect()->route('bo.pictobrands.index')->with('success', trans('Suppression faite avec succès')); } }