2023-12-25 22:51:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Form\Actions;
|
|
|
|
|
|
|
|
use App\Form\Models\Formtemplate;
|
2023-12-27 22:45:08 +01:00
|
|
|
use App\Lib\Events\Succeeded;
|
2023-12-25 22:51:07 +01:00
|
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
use Lorisleiva\Actions\ActionRequest;
|
|
|
|
use Lorisleiva\Actions\Concerns\AsAction;
|
|
|
|
|
|
|
|
class FormtemplateUpdateAction
|
|
|
|
{
|
|
|
|
use AsAction;
|
2023-12-26 20:24:57 +01:00
|
|
|
use HasValidation;
|
2023-12-25 22:51:07 +01:00
|
|
|
|
2023-12-26 20:06:57 +01:00
|
|
|
/**
|
|
|
|
* @return array<string, mixed>
|
|
|
|
*/
|
2023-12-25 22:51:07 +01:00
|
|
|
public function rules(): array
|
|
|
|
{
|
|
|
|
return [
|
2023-12-27 22:54:58 +01:00
|
|
|
...$this->globalRules(),
|
2023-12-25 22:51:07 +01:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2023-12-31 22:45:50 +01:00
|
|
|
/**
|
|
|
|
* @return array<string, mixed>
|
|
|
|
*/
|
|
|
|
public function getValidationAttributes(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
...$this->globalValidationAttributes(),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2023-12-25 22:51:07 +01:00
|
|
|
/**
|
|
|
|
* @param array<string, mixed> $attributes
|
|
|
|
*/
|
|
|
|
public function handle(Formtemplate $formtemplate, array $attributes): void
|
|
|
|
{
|
|
|
|
$formtemplate->update($attributes);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function asController(Formtemplate $formtemplate, ActionRequest $request): JsonResponse
|
|
|
|
{
|
|
|
|
$this->handle($formtemplate, $request->validated());
|
|
|
|
|
2023-12-27 22:45:08 +01:00
|
|
|
Succeeded::message('Vorlage aktualisiert.')->dispatch();
|
|
|
|
|
2023-12-25 22:51:07 +01:00
|
|
|
return response()->json([]);
|
|
|
|
}
|
|
|
|
}
|