From 9a00e6dc12fd5c9a59665df3e2e7f6e05f64cdd2 Mon Sep 17 00:00:00 2001 From: HolgerHatGarKeineNode Date: Mon, 6 Mar 2023 14:05:31 +0100 Subject: [PATCH] monthly meetups --- .../Livewire/Meetup/Form/MeetupEventForm.php | 18 ++++++++++-------- .../meetup/form/meetup-event-form.blade.php | 8 ++++---- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/Http/Livewire/Meetup/Form/MeetupEventForm.php b/app/Http/Livewire/Meetup/Form/MeetupEventForm.php index 6f4c300a..bcc9baea 100644 --- a/app/Http/Livewire/Meetup/Form/MeetupEventForm.php +++ b/app/Http/Livewire/Meetup/Form/MeetupEventForm.php @@ -17,7 +17,7 @@ class MeetupEventForm extends Component public bool $recurring = false; - public int $repetitions = 52; + public int $repetitions = 12; public array $series = []; @@ -34,6 +34,7 @@ class MeetupEventForm extends Component 'meetupEvent.description' => 'string|nullable', 'meetupEvent.link' => 'url|nullable', + 'series' => 'array', 'series.*.start' => 'required', 'recurring' => 'bool', @@ -63,7 +64,7 @@ class MeetupEventForm extends Component public function updatedMeetupEventStart($value) { - $this->validate(); + $this->validateOnly('meetupEvent.start'); if ($this->recurring) { $this->updatedRecurring(true); } @@ -71,23 +72,24 @@ class MeetupEventForm extends Component public function updatedRecurring($value) { - $this->validate(); + $this->validateOnly('recurring'); + $series = []; if ($value && $this->meetupEvent->start) { - $this->series = []; for ($i = 0; $i < $this->repetitions; $i++) { - $this->series[] = [ - 'start' => $this->meetupEvent->start->addWeeks($i + 1) + $series[] = [ + 'start' => $this->meetupEvent->start->addMonths($i + 1) ->toDateTimeString(), ]; } } + $this->series = $series; } public function updatedRepetitions($value) { - $this->validate(); + $this->validateOnly('repetitions'); if ($this->recurring) { - $this->updatedRecurring(true); + $this->updatedRecurring(true, $value); } } diff --git a/resources/views/livewire/meetup/form/meetup-event-form.blade.php b/resources/views/livewire/meetup/form/meetup-event-form.blade.php index e982ab7a..a163b1ad 100644 --- a/resources/views/livewire/meetup/form/meetup-event-form.blade.php +++ b/resources/views/livewire/meetup/form/meetup-event-form.blade.php @@ -60,9 +60,9 @@ :placeholder="__('Start')"/> - @if(!$meetupEvent->id) - - + @if(!$meetupEvent->id && $meetupEvent->start) + +

{{ __('The recurring appointments are created in the database as new entries. Please be careful with this function, otherwise you will have to change or delete all the appointments you have created manually if you make an error.') }}

@endif @@ -91,7 +91,7 @@
- @if($meetupEvent->start && $recurring) + @if($recurring && count($series) === $repetitions)
@for($i = 0; $i < $repetitions; $i++)