diff --git a/app/Form/Actions/ParticipantStoreAction.php b/app/Form/Actions/ParticipantStoreAction.php new file mode 100644 index 00000000..db9d572d --- /dev/null +++ b/app/Form/Actions/ParticipantStoreAction.php @@ -0,0 +1,56 @@ + + */ + public function rules(): array + { + /** @var Form */ + $form = request()->route('form'); + + return $form->getRegistrationRules(); + } + + /** + * @return array + */ + public function getValidationAttributes(): array + { + /** @var Form */ + $form = request()->route('form'); + + return $form->getRegistrationAttributes(); + } + + /** + * @return array + */ + public function getValidationMessages(): array + { + /** @var Form */ + $form = request()->route('form'); + + return $form->getRegistrationMessages(); + } + + public function handle(Form $form, ActionRequest $request): JsonResponse + { + $form->participants()->create(['data' => $request->validated()]); + ExportSyncAction::dispatch($form->id); + Succeeded::message('Teilnehmer*in erstellt.')->dispatch(); + return response()->json([]); + } +} diff --git a/app/Form/Resources/ParticipantResource.php b/app/Form/Resources/ParticipantResource.php index 95ec8556..0c8cd739 100644 --- a/app/Form/Resources/ParticipantResource.php +++ b/app/Form/Resources/ParticipantResource.php @@ -60,12 +60,14 @@ class ParticipantResource extends JsonResource return [ 'filter' => ParticipantFilterScope::fromRequest(request()->input('filter', ''))->setForm($form), + 'form_config' => $form->config, 'default_filter_value' => ParticipantFilterScope::$nan, 'filters' => $filterData, 'form_meta' => $form->meta, 'has_nami_field' => $form->getFields()->hasNamiField(), 'links' => [ 'update_form_meta' => route('form.update-meta', ['form' => $form]), + 'store_participant' => route('form.participant.store', ['form' => $form]), ], 'columns' => $fieldData->push([ 'name' => 'Registriert am', diff --git a/resources/js/views/form/Participants.vue b/resources/js/views/form/Participants.vue index f8d04c79..1539bd27 100644 --- a/resources/js/views/form/Participants.vue +++ b/resources/js/views/form/Participants.vue @@ -1,8 +1,8 @@