From 502ba20b6d266ce70441e675758313c52fd2a2a1 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Tue, 2 Dec 2025 00:28:58 +0100 Subject: [PATCH] Add cancelled member data --- app/Form/Actions/FormIndexAction.php | 2 +- app/Form/Scopes/ParticipantFilterScope.php | 9 +++++++-- .../Form/Models/ParticipantFactory.php | 4 ++++ resources/js/views/form/Participants.vue | 1 + tests/EndToEnd/Form/FormIndexActionTest.php | 12 ++++++++++++ .../Form/ParticipantIndexActionTest.php | 19 +++++++++++++++++++ 6 files changed, 44 insertions(+), 3 deletions(-) diff --git a/app/Form/Actions/FormIndexAction.php b/app/Form/Actions/FormIndexAction.php index 21b116f4..49dc107f 100644 --- a/app/Form/Actions/FormIndexAction.php +++ b/app/Form/Actions/FormIndexAction.php @@ -20,7 +20,7 @@ class FormIndexAction */ public function handle(string $filter): LengthAwarePaginator { - return FormFilterScope::fromRequest($filter)->getQuery()->query(fn ($query) => $query->withCount('participants'))->paginate(15); + return FormFilterScope::fromRequest($filter)->getQuery()->query(fn ($query) => $query->withCount(['participants' => fn ($q) => $q->whereNull('cancelled_at')]))->paginate(15); } public function asController(ActionRequest $request): Response diff --git a/app/Form/Scopes/ParticipantFilterScope.php b/app/Form/Scopes/ParticipantFilterScope.php index d29c0a11..81835afb 100644 --- a/app/Form/Scopes/ParticipantFilterScope.php +++ b/app/Form/Scopes/ParticipantFilterScope.php @@ -32,7 +32,8 @@ class ParticipantFilterScope extends ScoutFilter public string $search = '', public array $options = [], public ?int $parent = null, - public ?Sorting $sort = null + public ?Sorting $sort = null, + public bool $showCancelled = false, ) { } @@ -54,7 +55,11 @@ class ParticipantFilterScope extends ScoutFilter $filter->push('parent-id IS NULL'); } - $filter->push('cancelled_at IS NULL'); + if ($this->showCancelled) { + $filter->push('cancelled_at IS NOT NULL'); + } else { + $filter->push('cancelled_at IS NULL'); + } if ($this->parent !== null && $this->parent !== -1) { $filter->push('parent-id = ' . $this->parent); diff --git a/database/factories/Form/Models/ParticipantFactory.php b/database/factories/Form/Models/ParticipantFactory.php index 5521ecab..3e0ab856 100644 --- a/database/factories/Form/Models/ParticipantFactory.php +++ b/database/factories/Form/Models/ParticipantFactory.php @@ -39,6 +39,10 @@ class ParticipantFactory extends Factory return $this->state(['data' => $data]); } + public function cancelled(): self { + return $this->state(['cancelled_at' => now()->subWeek()]); + } + public function nr(int $number): self { return $this->state(['member_id' => $number]); diff --git a/resources/js/views/form/Participants.vue b/resources/js/views/form/Participants.vue index 28a53ba0..b02220c0 100644 --- a/resources/js/views/form/Participants.vue +++ b/resources/js/views/form/Participants.vue @@ -29,6 +29,7 @@