feat: Add scanner user association to tickets; update Ticket model, resource, migration, and tests

This commit is contained in:
2026-08-05 09:17:09 -03:00
parent 2a15dc92be
commit e17d1fa15e
4 changed files with 39 additions and 0 deletions

View File

@@ -24,6 +24,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
'starts_at',
'expires_at',
'used_at',
'scanner_user_id',
'user_id',
])]
class Ticket extends Model
@@ -47,6 +48,7 @@ class Ticket extends Model
'starts_at' => 'datetime',
'expires_at' => 'datetime',
'used_at' => 'datetime',
'scanner_user_id' => 'integer',
'user_id' => 'integer',
];
}
@@ -63,6 +65,12 @@ class Ticket extends Model
return $this->belongsTo(User::class);
}
/** @return BelongsTo<User, $this> */
public function scannerUser(): BelongsTo
{
return $this->belongsTo(User::class, 'scanner_user_id');
}
/** @return BelongsTo<Purchase, $this> */
public function sourcePurchase(): BelongsTo
{

View File

@@ -23,6 +23,7 @@ class TicketResource extends JsonResource
'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,