adrema/app/Form/Actions/IsDirtyAction.php

33 lines
626 B
PHP
Raw Normal View History

2024-04-18 22:15:28 +02:00
<?php
namespace App\Form\Actions;
use App\Form\Models\Form;
use Illuminate\Http\JsonResponse;
use Lorisleiva\Actions\ActionRequest;
use Lorisleiva\Actions\Concerns\AsAction;
class IsDirtyAction
{
use AsAction;
2024-04-24 15:39:07 +02:00
/**
* @return array<string, mixed>
*/
2024-04-19 11:38:53 +02:00
public function rules(): array
{
return [
'config' => 'array|present',
];
}
2024-04-18 22:15:28 +02:00
public function handle(Form $form, ActionRequest $request): JsonResponse
{
$form->config = $request->input('config');
return response()->json([
'result' => $form->isDirty('config'),
]);
}
}