diff --git a/api/app/Rules/Artist/ContractRequiresFee.php b/api/app/Rules/Artist/ContractRequiresFee.php new file mode 100644 index 00000000..63021c68 --- /dev/null +++ b/api/app/Rules/Artist/ContractRequiresFee.php @@ -0,0 +1,40 @@ +bookingStatus !== ArtistEngagementStatus::Contracted->value) { + return; + } + + if ($value === null || $value === '') { + $fail('Bij status "Gecontracteerd" is een fee verplicht.'); + + return; + } + + if ((float) $value <= 0) { + $fail('De fee moet groter dan 0 zijn.'); + } + } +} diff --git a/api/app/Rules/Artist/OptionExpiresInFuture.php b/api/app/Rules/Artist/OptionExpiresInFuture.php new file mode 100644 index 00000000..cfc67eb6 --- /dev/null +++ b/api/app/Rules/Artist/OptionExpiresInFuture.php @@ -0,0 +1,42 @@ +bookingStatus !== ArtistEngagementStatus::Option->value) { + return; + } + + if ($value === null || $value === '') { + $fail('Bij status "Optie" is een vervaldatum verplicht.'); + + return; + } + + $candidate = CarbonImmutable::parse((string) $value); + if ($candidate->isPast()) { + $fail('De optie-vervaldatum moet in de toekomst liggen.'); + } + } +} diff --git a/api/app/Rules/Artist/StageActiveOnEvent.php b/api/app/Rules/Artist/StageActiveOnEvent.php new file mode 100644 index 00000000..5dfde581 --- /dev/null +++ b/api/app/Rules/Artist/StageActiveOnEvent.php @@ -0,0 +1,43 @@ +eventId === null) { + return; + } + + $exists = StageDay::query() + ->where('stage_id', (string) $value) + ->where('event_id', $this->eventId) + ->exists(); + + if (! $exists) { + $fail('De gekozen stage is niet actief op deze (sub-)event.'); + } + } +} diff --git a/api/app/Rules/Artist/WithinEventBounds.php b/api/app/Rules/Artist/WithinEventBounds.php new file mode 100644 index 00000000..255d8118 --- /dev/null +++ b/api/app/Rules/Artist/WithinEventBounds.php @@ -0,0 +1,51 @@ +eventId === null) { + return; + } + + $event = Event::withoutGlobalScopes()->find($this->eventId); + if ($event === null) { + return; + } + + $candidate = CarbonImmutable::parse((string) $value); + $start = CarbonImmutable::instance($event->start_at); + $end = CarbonImmutable::instance($event->end_at); + + if ($candidate->lt($start) || $candidate->gt($end)) { + $fail(sprintf( + 'De datum moet binnen het evenement (%s — %s) vallen.', + $start->format('Y-m-d H:i'), + $end->format('Y-m-d H:i'), + )); + } + } +}