ldc-domaine-de-lanvaux/app/Http/Controllers/Bo/WhoareweIconDetailsController.php

46 lines
1.6 KiB
PHP
Raw Permalink Normal View History

2022-08-05 09:38:44 +00:00
<?php
namespace App\Http\Controllers\Bo;
use App\Http\Controllers\Controller;
use App\Http\Requests\StoreWhoareweIconDetailRequest;
use App\Models\WhoareweIconDetail;
2022-11-16 10:51:43 +01:00
use Illuminate\Support\Facades\DB;
2022-08-05 09:38:44 +00:00
class WhoareweIconDetailsController extends Controller
{
/**
* Show the form for editing the specified resource.
*
* @param WhoareweIconDetail $whoareweicondetail
* @return \Illuminate\Contracts\View\View
* @ignore phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
*/
public function edit(WhoareweIconDetail $whoareweicondetail): \Illuminate\Contracts\View\View
{
return view('back.whoarewe_icon_details.edit', compact('whoareweicondetail'));
2022-08-05 09:38:44 +00:00
}
/**
* Update the specified resource in storage.
*
* @param StoreWhoareweIconDetailRequest $request
* @param WhoareweIconDetail $whoareweicondetail
* @return \Illuminate\Http\RedirectResponse
* @ignore phpcs:disable Generic.Files.LineLength.TooLong
*/
public function update(StoreWhoareweIconDetailRequest $request, WhoareweIconDetail $whoareweicondetail): \Illuminate\Http\RedirectResponse
{
2022-11-16 10:51:43 +01:00
return DB::transaction(function () use ($request, $whoareweicondetail) {
$whoareweicondetail->fill($request->validated());
2022-08-05 09:38:44 +00:00
2022-11-16 10:51:43 +01:00
if ($whoareweicondetail->saveOrFail()) {
2026-10-27 15:12:56 +01:00
return to_route('bo.whoareweicondetails.edit', $whoareweicondetail->slug)
2022-11-16 10:51:43 +01:00
->with('success', trans(__('Changes_saved')));
}
2022-08-05 09:38:44 +00:00
2022-11-16 10:51:43 +01:00
return back()->with('error', trans(__('Changes_failed')));
});
2022-08-05 09:38:44 +00:00
}
}