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

48 lines
1.7 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\StoreWhoareweExpertiseDetailRequest;
use App\Models\WhoareweExpertiseDetail;
2022-11-16 10:51:43 +01:00
use Illuminate\Support\Facades\DB;
2022-08-05 09:38:44 +00:00
2024-01-22 15:19:45 +01:00
class WhoareweExpertiseDetailsController extends Controller
2022-08-05 09:38:44 +00:00
{
/**
* Show the form for editing the specified resource.
*
* @param WhoareweExpertiseDetail $whoareweexpertisedetail
* @return \Illuminate\Contracts\View\View
* @ignore phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
*/
public function edit(WhoareweExpertiseDetail $whoareweexpertisedetail): \Illuminate\Contracts\View\View
{
return view('back.whoarewe_expertise_details.edit', compact('whoareweexpertisedetail'));
2022-08-05 09:38:44 +00:00
}
/**
* Update the specified resource in storage.
*
* @param StoreWhoareweExpertiseDetailRequest $request
* @param WhoareweExpertiseDetail $whoareweexpertisedetail
* @return \Illuminate\Http\RedirectResponse
*/
public function update(
StoreWhoareweExpertiseDetailRequest $request,
WhoareweExpertiseDetail $whoareweexpertisedetail
): \Illuminate\Http\RedirectResponse {
2022-11-16 10:51:43 +01:00
return DB::transaction(function () use ($request, $whoareweexpertisedetail) {
$whoareweexpertisedetail->fill($request->validated());
2022-08-05 09:38:44 +00:00
2022-11-16 10:51:43 +01:00
if ($whoareweexpertisedetail->saveOrFail()) {
2026-10-27 15:12:56 +01:00
return to_route('bo.whoareweexpertisedetails.edit', $whoareweexpertisedetail->slug)
2022-11-16 10:51:43 +01:00
->with('success', trans(__('Changes_saved')));
}
2022-08-05 09:38:44 +00:00
2026-10-27 15:12:56 +01:00
return to_route('bo.whoareweexpertisedetails.edit', $whoareweexpertisedetail->slug)
2022-11-16 10:51:43 +01:00
->with('error', trans(__('Changes_failed')));
});
2022-08-05 09:38:44 +00:00
}
}