<?php

namespace App\Models;

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

/** 主站 ↔ 彩票划转订单 {@see transfer_orders} */
final class TransferOrder extends Model
{
    protected $fillable = [
        'transfer_no',
        'player_id',
        'direction',
        'currency_code',
        'amount',
        'idempotent_key',
        'status',
        'external_request_payload',
        'external_response_payload',
        'external_ref_no',
        'fail_reason',
        'finished_at',
    ];

    protected function casts(): array
    {
        return [
            'amount' => 'integer',
            'external_request_payload' => 'array',
            'external_response_payload' => 'array',
            'finished_at' => 'datetime',
        ];
    }

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