adrema/app/Form/Actions/ParticipantUpdateAction.php

33 lines
738 B
PHP
Raw Normal View History

2024-07-12 20:15:24 +02:00
<?php
namespace App\Form\Actions;
use App\Form\Models\Participant;
use App\Lib\Events\Succeeded;
use Illuminate\Http\JsonResponse;
use Lorisleiva\Actions\ActionRequest;
use Lorisleiva\Actions\Concerns\AsAction;
class ParticipantUpdateAction
{
use AsAction;
2024-07-12 20:42:30 +02:00
/**
* @return array<string, mixed>
*/
2024-07-12 20:15:24 +02:00
public function rules(): array
{
return [
'data' => 'required',
];
}
public function handle(Participant $participant, ActionRequest $request): JsonResponse
{
$participant->update(['data' => [...$participant->data, ...$request->validated('data')]]);
Succeeded::message('Teilnehmer*in bearbeitet.')->dispatch();
return response()->json([]);
}
}