feat(ticketing): resolve validity in tenant timezone
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
namespace App\Domains\Ticketing\Event\Models;
|
||||
|
||||
use App\Domains\Commerce\Catalog\Models\Variant;
|
||||
use App\Domains\Core\Tenant\Models\Tenant;
|
||||
use App\Domains\Ticketing\Event\Enums\EventDateStatus;
|
||||
use App\Domains\Ticketing\Event\Services\EffectiveEventDateResolver;
|
||||
use App\Domains\Ticketing\Event\Services\EventDateTextFormatter;
|
||||
use App\Domains\Core\Tenant\Models\Tenant;
|
||||
use App\Domains\Ticketing\Ticket\Enums\ValidityTimeType;
|
||||
use App\Domains\Ticketing\Ticket\Models\ValidityTime;
|
||||
use Carbon\CarbonInterface;
|
||||
@@ -131,12 +131,12 @@ class EventDate extends Model
|
||||
|
||||
public function startsAt(): CarbonInterface
|
||||
{
|
||||
return Carbon::parse($this->date->format('Y-m-d').' '.$this->time_start);
|
||||
return Carbon::parse($this->date->format('Y-m-d').' '.$this->time_start, $this->tenant->timezone);
|
||||
}
|
||||
|
||||
public function endsAt(): CarbonInterface
|
||||
{
|
||||
$endsAt = Carbon::parse($this->date->format('Y-m-d').' '.$this->time_end);
|
||||
$endsAt = Carbon::parse($this->date->format('Y-m-d').' '.$this->time_end, $this->tenant->timezone);
|
||||
|
||||
return $endsAt->lessThanOrEqualTo($this->startsAt())
|
||||
? $endsAt->addDay()
|
||||
@@ -184,8 +184,8 @@ class EventDate extends Model
|
||||
|
||||
private function syncValidityTime(): void
|
||||
{
|
||||
$startsAt = $this->startsAt();
|
||||
$expiresAt = $this->endsAt();
|
||||
$startsAt = $this->startsAt()->utc();
|
||||
$expiresAt = $this->endsAt()->utc();
|
||||
|
||||
$attributes = [
|
||||
'type' => ValidityTimeType::FixedWindow,
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace App\Domains\Ticketing\Event\Resources;
|
||||
use App\Domains\Commerce\Catalog\Enums\InventoryPolicy;
|
||||
use App\Domains\Commerce\Catalog\Models\CatalogItem;
|
||||
use App\Domains\Commerce\Catalog\Models\Variant;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
@@ -29,10 +28,7 @@ class PublicEventResource extends JsonResource
|
||||
return null;
|
||||
}
|
||||
|
||||
return Carbon::parse(
|
||||
$first->date->format('Y-m-d').' '.$first->time_start,
|
||||
config('app.event_timezone'),
|
||||
)->toISOString();
|
||||
return $first->startsAt()->toISOString();
|
||||
}),
|
||||
'dates' => $this->whenLoaded('dates', fn () => $this->dates->map(fn ($date): array => [
|
||||
'id' => $date->id,
|
||||
@@ -52,8 +48,7 @@ class PublicEventResource extends JsonResource
|
||||
'description' => $item->descripcion,
|
||||
'price' => $item->precio,
|
||||
'image' => $item->attachments->first()?->getTemporaryUrl(1440),
|
||||
'requires_selection' => $item->itemAttributes->contains(fn ($attribute): bool =>
|
||||
$attribute->show_in_selector && $attribute->attribute?->codigo !== 'event_date'),
|
||||
'requires_selection' => $item->itemAttributes->contains(fn ($attribute): bool => $attribute->show_in_selector && $attribute->attribute?->codigo !== 'event_date'),
|
||||
'maximum_quantity' => $item->inventory_policy === InventoryPolicy::Unlimited
|
||||
? null
|
||||
: $item->availableStock(),
|
||||
|
||||
Reference in New Issue
Block a user