adrema/app/Letter/SettingSaveAction.php

43 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2022-10-18 14:28:46 +02:00
<?php
2022-11-07 16:18:11 +01:00
namespace App\Letter;
2022-10-18 14:28:46 +02:00
use Illuminate\Http\RedirectResponse;
use Lorisleiva\Actions\ActionRequest;
use Lorisleiva\Actions\Concerns\AsAction;
class SettingSaveAction
{
use AsAction;
/**
* @param array<string, string> $input
*/
public function handle(array $input): void
{
2022-11-07 16:18:11 +01:00
$settings = app(LetterSettings::class);
2022-10-18 14:28:46 +02:00
$settings->fill([
'from_long' => $input['from_long'] ?? '',
'from' => $input['from'] ?? '',
'mobile' => $input['mobile'] ?? '',
'email' => $input['email'] ?? '',
'website' => $input['website'] ?? '',
'address' => $input['address'] ?? '',
'place' => $input['place'] ?? '',
'zip' => $input['zip'] ?? '',
2022-11-17 23:59:43 +01:00
'iban' => $input['iban'] ?? '',
'bic' => $input['bic'] ?? '',
2022-10-18 14:28:46 +02:00
]);
$settings->save();
}
public function asController(ActionRequest $request): RedirectResponse
{
$this->handle($request->all());
return redirect()->back()->success('Einstellungen gespeichert');
}
}