feat(ticket): add tickets endpoint and resource for sales; implement ticket retrieval logic and tests

This commit is contained in:
2026-08-11 11:20:55 -03:00
parent a458c564ca
commit 2115d2384d
7 changed files with 136 additions and 1 deletions

View File

@@ -30,12 +30,19 @@ class Ticket extends Model
{
use HasFactory;
public const STATUS_ACTIVE = 'active';
public const STATUS_EXPIRED = 'expired';
public const STATUS_USED = 'used';
public $timestamps = false;
protected $appends = [
'is_valid',
'is_expired',
'is_used',
'status',
];
protected function casts(): array
@@ -121,6 +128,19 @@ class Ticket extends Model
return $this->used_at !== null;
}
public function getStatusAttribute(): string
{
if ($this->is_used) {
return self::STATUS_USED;
}
if ($this->is_expired) {
return self::STATUS_EXPIRED;
}
return self::STATUS_ACTIVE;
}
public function getEffectiveStartsAt(): ?CarbonInterface
{
return $this->validityTime?->startsAt();