<?php

namespace App\Models;

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

/**
 * {@see risk_cap_items}
 *
 * `cap_amount`：与钱包一致的最小货币单位（整数）。
 */
final class RiskCapItem extends Model
{
    protected $fillable = [
        'version_id',
        'draw_id',
        'normalized_number',
        'cap_amount',
        'cap_type',
    ];

    protected function casts(): array
    {
        return [
            'version_id' => 'integer',
            'draw_id' => 'integer',
            'cap_amount' => 'integer',
        ];
    }

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

    /** @return BelongsTo<Draw, RiskCapItem> */
    public function draw(): BelongsTo
    {
        return $this->belongsTo(Draw::class, 'draw_id');
    }
}
