<?php

namespace App\Models;

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

/**
 * {@see odds_items}
 *
 * `odds_value`：整数，**赔率乘数 × 10000**（例如 19500 表示 1.9500 倍）。
 */
final class OddsItem extends Model
{
    protected $fillable = [
        'version_id',
        'play_code',
        'prize_scope',
        'dimension',
        'odds_value',
        'rebate_rate',
        'commission_rate',
        'currency_code',
        'extra_config_json',
    ];

    protected function casts(): array
    {
        return [
            'version_id' => 'integer',
            'dimension' => 'integer',
            'odds_value' => 'integer',
            'rebate_rate' => 'decimal:4',
            'commission_rate' => 'decimal:4',
            'extra_config_json' => 'json',
        ];
    }

    /** @return BelongsTo<OddsVersion, OddsItem> */
    public function version(): BelongsTo
    {
        return $this->belongsTo(OddsVersion::class, 'version_id');
    }
}
