ldc-agis/app/Http/Controllers/Bo/ConvictionpageController.php

55 lines
2 KiB
PHP
Raw Permalink Normal View History

2023-10-23 16:29:49 +02:00
<?php
namespace App\Http\Controllers\Bo;
use App\Http\Controllers\Controller;
use App\Http\Requests\Bo\Convictionpages\UpdateConvictionpageRequest;
use App\Models\Convictionpage;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class ConvictionpageController extends Controller
{
/**
* Show the form for editing the specified resource.
2023-10-23 16:29:49 +02:00
*
* @return \Illuminate\Contracts\View\View
*/
public function edit(): \Illuminate\Contracts\View\View
2023-10-23 16:29:49 +02:00
{
$this->authorize('update', \App\Models\Convictionpage::class);
2023-10-23 16:29:49 +02:00
/** @var \App\Models\Convictionpage $convictionpageModel */
$convictionpageModel = Convictionpage::query()->firstOrFail();
2023-10-23 16:29:49 +02:00
return view('bo.pages.convictionpages.edit', compact('convictionpageModel'));
2023-10-23 16:29:49 +02:00
}
/**
* Update the specified resource in storage.
*
* @param \App\Http\Requests\Bo\Convictionpages\UpdateConvictionpageRequest $request
* @return \Illuminate\Http\RedirectResponse
*/
public function update(UpdateConvictionpageRequest $request): \Illuminate\Http\RedirectResponse
{
$this->authorize('update', \App\Models\Convictionpage::class);
return DB::transaction(function () use ($request) {
/** @var \App\Models\Convictionpage $convictionpageModel */
$convictionpageModel = Convictionpage::query()->firstOrFail();
if (($convictionpageModel->fill($request->validated()))->saveOrFail()) {
return redirect()->route('bo.convictionpages.edit')
2023-10-23 16:29:49 +02:00
->with('success', __('crud.messages.has_been_updated', [
'model' => Str::ucfirst(__('models.classes.convictionpage'))
]));
}
return redirect()->route('bo.convictionpages.edit')
2023-10-23 16:29:49 +02:00
->with('error', __('crud.messages.cannot_be_updated', [
'model' => Str::ucfirst(__('models.classes.convictionpage'))
]));
});
}
}