2023-12-15 15:53:55 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Bo;
|
|
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
use App\Http\Requests\Bo\KlubBlocs\UpdateKlubBlocRequest;
|
|
|
|
|
use App\Models\KlubBloc;
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
|
|
|
|
|
class KlubBlocController extends Controller
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Create the controller instance.
|
|
|
|
|
*/
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
$this->authorizeResource(KlubBloc::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Show the form for editing the specified resource.
|
|
|
|
|
*
|
2024-01-26 16:24:14 +01:00
|
|
|
* @param \App\Models\KlubBloc $klubBloc
|
2023-12-15 15:53:55 +00:00
|
|
|
* @return \Illuminate\Contracts\View\View
|
|
|
|
|
*/
|
|
|
|
|
public function edit(KlubBloc $klubBloc): \Illuminate\Contracts\View\View
|
|
|
|
|
{
|
|
|
|
|
return view('bo.pages.klub_blocs.edit', ['klubBlocModel' => $klubBloc]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update the specified resource in storage.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Http\Requests\Bo\KlubBlocs\UpdateKlubBlocRequest $request
|
|
|
|
|
* @param \App\Models\KlubBloc $klubBloc
|
|
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
|
|
|
*/
|
|
|
|
|
public function update(
|
|
|
|
|
UpdateKlubBlocRequest $request,
|
|
|
|
|
KlubBloc $klubBloc
|
|
|
|
|
): \Illuminate\Http\RedirectResponse {
|
|
|
|
|
return DB::transaction(function () use ($request, $klubBloc) {
|
|
|
|
|
$klubBloc->fill($request->validated());
|
|
|
|
|
|
|
|
|
|
if ($klubBloc->saveOrFail()) {
|
|
|
|
|
return redirect()->route('bo.klubblocs.edit', $klubBloc)
|
|
|
|
|
->with('success', __('crud.messages.has_been_updated', [
|
|
|
|
|
'model' => Str::ucfirst(__('models.classes.klub_bloc'))
|
|
|
|
|
]));
|
|
|
|
|
}
|
|
|
|
|
return redirect()->route('bo.klubblocs.edit', $klubBloc)
|
|
|
|
|
->with('error', __('crud.messages.cannot_be_updated', [
|
|
|
|
|
'model' => Str::ucfirst(__('models.classes.klub_bloc'))
|
|
|
|
|
]));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|