- Added `ticket_generation_policy` column to `catalog_items` table to manage ticket generation strategies. - Created `ticket_validity_times` table to allow multiple validity times per ticket. - Introduced `validity_time_id` column in `event_dates` table to associate event dates with validity times. - Established `ticket_validity_groups` and `ticket_validity_group_times` tables to group validity times for tickets. - Updated seeder to set default ticket generation policy for specific tenant. - Enhanced tests to cover new functionality, including ticket generation based on event dates and validity times. - Refactored ticket validity checks to accommodate multiple validity times in a group.
37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Ticket\Resources;
|
|
|
|
use App\Domains\Ticket\Models\Ticket;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
/** @mixin Ticket */
|
|
class TicketResource extends JsonResource
|
|
{
|
|
/** @return array<string, mixed> */
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'tenant_code' => $this->tenant_code,
|
|
'ticket' => $this->ticket,
|
|
'name' => $this->name,
|
|
'description' => $this->description,
|
|
'source_catalog_item_id' => $this->source_catalog_item_id,
|
|
'source_variant_id' => $this->source_variant_id,
|
|
'validity_times' => ValidityTimeResource::collection($this->allValidityTimes()),
|
|
'validity_groups' => TicketValidityGroupResource::collection(
|
|
$this->resolvedValidityGroups()
|
|
),
|
|
'starts_at' => $this->getEffectiveStartsAt(),
|
|
'expires_at' => $this->getEffectiveExpiresAt(),
|
|
'used_at' => $this->used_at,
|
|
'scanner_user_id' => $this->scanner_user_id,
|
|
'is_valid' => $this->is_valid,
|
|
'is_expired' => $this->is_expired,
|
|
'is_used' => $this->is_used,
|
|
];
|
|
}
|
|
}
|