<?php

namespace App\Models;

use App\Models\Seat;
use Illuminate\Database\Eloquent\Model;

class MatchModel extends Model
{
    protected $table = 'matches';
    protected $primaryKey = 'match_id';
    public $incrementing = true;
    public $timestamps = true;

    protected $fillable = [
        'tournament_name',
        'home_team',
        'home_team_flag',
        'away_team',
        'away_team_flag',
        'match_date',
        'stadium',
        'vvip_amount',
        'vip_amount',
        '1st_class_amount',
        'total_ticket_number',
    ];

    protected $casts = [
        'match_date' => 'datetime',
    ];

    public function seats()
    {
        return $this->belongsToMany(Seat::class, 'match_seat', 'match_id', 'seat_id')->withPivot('available_tickets');
    }
}
