adrema/app/Form/Actions/FormtemplateUpdateAction.php

40 lines
854 B
PHP
Raw Normal View History

2023-12-25 22:51:07 +01:00
<?php
namespace App\Form\Actions;
use App\Form\Models\Formtemplate;
use Illuminate\Http\JsonResponse;
use Lorisleiva\Actions\ActionRequest;
use Lorisleiva\Actions\Concerns\AsAction;
class FormtemplateUpdateAction
{
use AsAction;
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 [
'name' => 'required|string|max:255',
'config' => '',
];
}
/**
* @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());
return response()->json([]);
}
}