feat(event): suspend event dates instead of cancelling
This commit is contained in:
@@ -68,9 +68,9 @@ class EventService
|
||||
return DB::transaction(function () use ($tenant, $eventDate, $data): EventDate {
|
||||
$source = $this->lockedDateForTenant($tenant, $eventDate);
|
||||
|
||||
if ($source->cancelled_at !== null) {
|
||||
if ($source->suspended_at !== null) {
|
||||
throw ValidationException::withMessages([
|
||||
'event_date' => ['No se puede reprogramar una fecha cancelada.'],
|
||||
'event_date' => ['No se puede reprogramar una fecha suspendida.'],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -111,22 +111,22 @@ class EventService
|
||||
});
|
||||
}
|
||||
|
||||
public function cancelDateForTenant(Tenant $tenant, EventDate $eventDate): EventDate
|
||||
public function suspendDateForTenant(Tenant $tenant, EventDate $eventDate): EventDate
|
||||
{
|
||||
return DB::transaction(function () use ($tenant, $eventDate): EventDate {
|
||||
$date = $this->lockedDateForTenant($tenant, $eventDate);
|
||||
|
||||
if ($date->rescheduled_to_event_date_id !== null) {
|
||||
throw ValidationException::withMessages([
|
||||
'event_date' => ['No se puede cancelar una fecha que ya fue reprogramada.'],
|
||||
'event_date' => ['No se puede suspender una fecha que ya fue reprogramada.'],
|
||||
]);
|
||||
}
|
||||
|
||||
if ($date->cancelled_at !== null) {
|
||||
if ($date->suspended_at !== null) {
|
||||
return $date->load('validityTime');
|
||||
}
|
||||
|
||||
$date->update(['cancelled_at' => now()]);
|
||||
$date->update(['suspended_at' => now()]);
|
||||
$this->disableTicketsWithoutUsableDates($tenant, $date);
|
||||
|
||||
return $date->fresh('validityTime');
|
||||
@@ -166,9 +166,9 @@ class EventService
|
||||
return $current->is($expected);
|
||||
}
|
||||
|
||||
private function disableTicketsWithoutUsableDates(Tenant $tenant, EventDate $cancelledDate): void
|
||||
private function disableTicketsWithoutUsableDates(Tenant $tenant, EventDate $suspendedDate): void
|
||||
{
|
||||
$affectedDateIds = collect([$cancelledDate->getKey()]);
|
||||
$affectedDateIds = collect([$suspendedDate->getKey()]);
|
||||
$frontier = $affectedDateIds;
|
||||
|
||||
while ($frontier->isNotEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user