From 445a8ae962d97fe3f44912c974c260c99368370a Mon Sep 17 00:00:00 2001 From: philipp lang Date: Tue, 2 Jul 2024 18:04:55 +0200 Subject: [PATCH] Add assign for participant --- app/Form/Actions/ParticipantAssignAction.php | 27 +++++++++++ app/Form/Resources/ParticipantResource.php | 2 + resources/img/svg/warning-triangle.svg | 1 + resources/js/views/form/MemberAssign.vue | 46 +++++++++++++++++++ resources/js/views/form/Participants.vue | 35 ++++++++++---- routes/web.php | 2 + .../Form/ParticipantAssignActionTest.php | 26 +++++++++++ .../Form/ParticipantIndexActionTest.php | 4 +- 8 files changed, 133 insertions(+), 10 deletions(-) create mode 100644 app/Form/Actions/ParticipantAssignAction.php create mode 100644 resources/img/svg/warning-triangle.svg create mode 100644 resources/js/views/form/MemberAssign.vue create mode 100644 tests/Feature/Form/ParticipantAssignActionTest.php diff --git a/app/Form/Actions/ParticipantAssignAction.php b/app/Form/Actions/ParticipantAssignAction.php new file mode 100644 index 00000000..a0a4c34f --- /dev/null +++ b/app/Form/Actions/ParticipantAssignAction.php @@ -0,0 +1,27 @@ + + */ + public function rules(): array + { + return [ + 'member_id' => 'required|exists:members,id', + ]; + } + + public function handle(Participant $participant, ActionRequest $request): void + { + $participant->update(['member_id' => $request->input('member_id')]); + } +} diff --git a/app/Form/Resources/ParticipantResource.php b/app/Form/Resources/ParticipantResource.php index b5029e62..36c65dd6 100644 --- a/app/Form/Resources/ParticipantResource.php +++ b/app/Form/Resources/ParticipantResource.php @@ -27,7 +27,9 @@ class ParticipantResource extends JsonResource 'created_at' => $this->created_at->format('Y-m-d H:i:s'), 'created_at_display' => $this->created_at->format('d.m.Y'), 'children_count' => $this->children_count, + 'member_id' => $this->member_id, 'links' => [ + 'assign' => route('participant.assign', ['participant' => $this->getModel()]), 'destroy' => route('participant.destroy', ['participant' => $this->getModel()]), 'children' => route('form.participant.index', ['form' => $this->form, 'parent' => $this->id]) ] diff --git a/resources/img/svg/warning-triangle.svg b/resources/img/svg/warning-triangle.svg new file mode 100644 index 00000000..ff4566ba --- /dev/null +++ b/resources/img/svg/warning-triangle.svg @@ -0,0 +1 @@ + diff --git a/resources/js/views/form/MemberAssign.vue b/resources/js/views/form/MemberAssign.vue new file mode 100644 index 00000000..7191793f --- /dev/null +++ b/resources/js/views/form/MemberAssign.vue @@ -0,0 +1,46 @@ + + + diff --git a/resources/js/views/form/Participants.vue b/resources/js/views/form/Participants.vue index 8b04d665..4d5eb792 100644 --- a/resources/js/views/form/Participants.vue +++ b/resources/js/views/form/Participants.vue @@ -1,5 +1,8 @@