77 lines
2.6 KiB
PHP
77 lines
2.6 KiB
PHP
<?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
|
|
{
|
|
/**
|
|
* Create the controller instance.
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->authorizeResource(Convictionpage::class);
|
|
}
|
|
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function index(): \Illuminate\Contracts\View\View
|
|
{
|
|
/** @var \Illuminate\Database\Eloquent\Builder $convictionpageModels */
|
|
$convictionpageModels = Convictionpage::query();
|
|
|
|
/** Sort columns with a query */
|
|
$this->sortQuery($convictionpageModels);
|
|
|
|
/** Custom pagination */
|
|
$convictionpageModels = $this->paginate($convictionpageModels);
|
|
|
|
return view('bo.pages.convictionpages.index', compact('convictionpageModels'));
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*
|
|
* @param App\Models\Convictionpage $convictionpage
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function edit(Convictionpage $convictionpage): \Illuminate\Contracts\View\View
|
|
{
|
|
return view('bo.pages.convictionpages.edit', ['convictionpageModel' => $convictionpage]);
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*
|
|
* @param \App\Http\Requests\Bo\Convictionpages\UpdateConvictionpageRequest $request
|
|
* @param \App\Models\Convictionpage $convictionpage
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function update(
|
|
UpdateConvictionpageRequest $request,
|
|
Convictionpage $convictionpage
|
|
): \Illuminate\Http\RedirectResponse {
|
|
return DB::transaction(function () use ($request, $convictionpage) {
|
|
$convictionpage->fill($request->validated());
|
|
|
|
if ($convictionpage->saveOrFail()) {
|
|
return redirect()->route('bo.convictionpages.edit', $convictionpage)
|
|
->with('success', __('crud.messages.has_been_updated', [
|
|
'model' => Str::ucfirst(__('models.classes.convictionpage'))
|
|
]));
|
|
}
|
|
return redirect()->route('bo.convictionpages.edit', $convictionpage)
|
|
->with('error', __('crud.messages.cannot_be_updated', [
|
|
'model' => Str::ucfirst(__('models.classes.convictionpage'))
|
|
]));
|
|
});
|
|
}
|
|
}
|