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