<?php

namespace App\Models;

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

/** {@see play_config_items} — 与 {@see PlayType::play_code} 对齐。 */
final class PlayConfigItem extends Model
{
    protected $fillable = [
        'version_id',
        'play_code',
        'category',
        'dimension',
        'bet_mode',
        'display_name',
        'is_enabled',
        'min_bet_amount',
        'max_bet_amount',
        'display_order',
        'supports_multi_number',
        'rule_text_zh',
        'rule_text_en',
        'rule_text_ne',
        'reserved_rule_json',
        'extra_config_json',
    ];

    protected function casts(): array
    {
        return [
            'version_id' => 'integer',
            'dimension' => 'integer',
            'is_enabled' => 'boolean',
            'min_bet_amount' => 'integer',
            'max_bet_amount' => 'integer',
            'display_order' => 'integer',
            'supports_multi_number' => 'boolean',
            'reserved_rule_json' => 'json',
            'extra_config_json' => 'json',
        ];
    }

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

    /** @return BelongsTo<PlayType, PlayConfigItem> */
    public function playType(): BelongsTo
    {
        return $this->belongsTo(PlayType::class, 'play_code', 'play_code');
    }
}
