diff --git a/app/Form/Actions/ParticipantDestroyAction.php b/app/Form/Actions/ParticipantDestroyAction.php new file mode 100644 index 00000000..bc6777a6 --- /dev/null +++ b/app/Form/Actions/ParticipantDestroyAction.php @@ -0,0 +1,36 @@ +delete(); + } + + public function asController(Participant $participant): void + { + $this->startJob($participant->id); + } + + /** + * @param mixed $parameters + */ + public function jobState(WithJobState $jobState, ...$parameters): WithJobState + { + return $jobState + ->after('Teilnehmer gelöscht.') + ->failed('Löschen von Teilnehmer fehlgeschlagen.') + ->shouldReload(JobChannels::make()->add('participant')); + } +} diff --git a/app/Form/Resources/ParticipantResource.php b/app/Form/Resources/ParticipantResource.php index 2e300cba..a1413e0a 100644 --- a/app/Form/Resources/ParticipantResource.php +++ b/app/Form/Resources/ParticipantResource.php @@ -24,6 +24,9 @@ class ParticipantResource extends JsonResource ...$this->getModel()->getFields()->present(), 'created_at' => $this->created_at->format('Y-m-d H:i:s'), 'created_at_display' => $this->created_at->format('d.m.Y'), + 'links' => [ + 'destroy' => route('participant.destroy', ['participant' => $this->getModel()]), + ] ]; } diff --git a/resources/js/views/form/Participants.vue b/resources/js/views/form/Participants.vue index ca4a68c7..83e22196 100644 --- a/resources/js/views/form/Participants.vue +++ b/resources/js/views/form/Participants.vue @@ -1,5 +1,14 @@