<?php

namespace App\Models;

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

/** 单条中奖号码行（与界面文档奖项分区对应） {@see draw_result_items} */
final class DrawResultItem extends Model
{
    public const UPDATED_AT = null;

    protected $fillable = [
        'draw_id',
        'result_batch_id',
        'prize_type',
        'prize_index',
        'number_4d',
        'suffix_3d',
        'suffix_2d',
        'head_digit',
        'tail_digit',
    ];

    protected function casts(): array
    {
        return [
            'prize_index' => 'integer',
            'head_digit' => 'integer',
            'tail_digit' => 'integer',
        ];
    }

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

    public function batch(): BelongsTo
    {
        return $this->belongsTo(DrawResultBatch::class, 'result_batch_id');
    }
}
