<?php

namespace App\Models;

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

class Topup extends Model
{
    protected $fillable = [
        'topup_id',
        'user_id',
        'payment_method_id',
        'amount',
        'fee_flat',
        'fee_percent',
        'total_amount',
        'payment_code',
        'account_name',
        'status',
        'payment_ref',
        'proof_image',
        'note',
        'paid_at',
        'expired_at',
    ];

    protected $casts = [
        'paid_at'    => 'datetime',
        'expired_at' => 'datetime',
        'fee_percent'=> 'decimal:2',
    ];

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

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