<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class SportsMatch extends Model
{
    use HasFactory;

    protected $table = 'sports_matches';

    protected $fillable = [
        'video_id', 'user_id', 'status',
        'sport', 'title', 'event_name', 'match_type',
        'match_date', 'match_time',
        'participant1_name', 'participant2_name', 'referee_name', 'venue_name',
        'competition', 'participants', 'media', 'officials',
        'venue', 'result', 'segments', 'statistics', 'reviews',
    ];

    protected $casts = [
        'match_date'   => 'date',
        'competition'  => 'array',
        'participants' => 'array',
        'media'        => 'array',
        'officials'    => 'array',
        'venue'        => 'array',
        'result'       => 'array',
        'segments'     => 'array',
        'statistics'   => 'array',
        'reviews'      => 'array',
    ];

    public function video(): BelongsTo
    {
        return $this->belongsTo(Video::class);
    }

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

    public function isDraft(): bool
    {
        return $this->status === 'draft';
    }
}
