<?php

namespace App\Models;

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

/** 注单项结算明细 {@see ticket_settlement_details} */
final class TicketSettlementDetail extends Model
{
    protected $fillable = [
        'settlement_batch_id',
        'ticket_item_id',
        'matched_prize_tier',
        'win_amount',
        'jackpot_allocation_amount',
        'match_detail_json',
    ];

    protected function casts(): array
    {
        return [
            'settlement_batch_id' => 'integer',
            'ticket_item_id' => 'integer',
            'win_amount' => 'integer',
            'jackpot_allocation_amount' => 'integer',
            'match_detail_json' => 'json',
        ];
    }

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

    public function ticketItem(): BelongsTo
    {
        return $this->belongsTo(TicketItem::class, 'ticket_item_id');
    }
}
