<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Ticket extends Model
{
    protected $fillable = [
        'raffle_id',
        'ticket_number',
        'status',
        'user_id',
        'reseller_id',
        'transaction_id',
        'reserved_at',
        'expires_at',
        'sold_at',
    ];

    protected $casts = [
        'reserved_at' => 'datetime',
        'expires_at' => 'datetime',
        'sold_at' => 'datetime',
    ];

    public function raffle()
    {
        return $this->belongsTo(Raffle::class);
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function reseller()
    {
        return $this->belongsTo(ResellerProfile::class, 'reseller_id');
    }

    public function transaction()
    {
        return $this->belongsTo(Transaction::class);
    }
}
