<?php

namespace App\Models;

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

/** 风险池占用日志 {@see risk_pool_lock_logs} */
final class RiskPoolLockLog extends Model
{
    public $timestamps = false;

    protected $fillable = [
        'draw_id',
        'normalized_number',
        'ticket_item_id',
        'action_type',
        'amount',
        'source_reason',
        'created_at',
    ];

    protected function casts(): array
    {
        return [
            'draw_id' => 'integer',
            'ticket_item_id' => 'integer',
            'amount' => 'integer',
            'created_at' => 'datetime',
        ];
    }

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

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