51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace App\Http\Controllers\Bo;
|
||
|
|
|
||
|
|
use App\Actions\Settings\UpdateSettings;
|
||
|
|
use App\Contracts\Executor;
|
||
|
|
use App\Contracts\QueryInputEmpty;
|
||
|
|
use App\Http\Controllers\Controller;
|
||
|
|
use App\Http\Requests\Bo\Settings\UpdateSettingsRequest;
|
||
|
|
use App\Models\Setting;
|
||
|
|
use App\Queries\Settings\GetSettingsQuery;
|
||
|
|
use Illuminate\Contracts\View\View;
|
||
|
|
use Illuminate\Http\RedirectResponse;
|
||
|
|
use Illuminate\Support\Str;
|
||
|
|
|
||
|
|
class SettingsController extends Controller
|
||
|
|
{
|
||
|
|
public function __construct(
|
||
|
|
private readonly Executor $executor,
|
||
|
|
) {
|
||
|
|
}
|
||
|
|
|
||
|
|
public function edit(GetSettingsQuery $query): View
|
||
|
|
{
|
||
|
|
$this->authorize('view', Setting::class);
|
||
|
|
|
||
|
|
$setting = $this->executor->execute($query, new QueryInputEmpty());
|
||
|
|
|
||
|
|
return view('bo.settings.edit', [
|
||
|
|
'setting' => $setting,
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function update(UpdateSettingsRequest $request, UpdateSettings $action): RedirectResponse
|
||
|
|
{
|
||
|
|
$this->authorize('update', Setting::class);
|
||
|
|
|
||
|
|
$this->executor->execute(
|
||
|
|
$action,
|
||
|
|
$request->toUpdateSettingsInput(),
|
||
|
|
);
|
||
|
|
|
||
|
|
return to_route('bo.settings.edit')
|
||
|
|
->with('success', trans('crud.messages.has_been_updated', [
|
||
|
|
'model' => Str::ucfirst(trans_choice('models.classes.settings', 1)),
|
||
|
|
]));
|
||
|
|
}
|
||
|
|
}
|