<?php

namespace App\Models;

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

class BinaryMatchingIncome extends Model
{
    use HasFactory;

    protected $table = 'binary_matching_income';

    /**
     * @var array<int, string>
     */
    protected $fillable = [
        'user_id',
        'run_date',
        'left_bv',
        'right_bv',
        'matched_bv',
        'rate',
        'gross_income',
        'capping_deduction',
        'net_income',
        'status',
        'reference',
    ];

    /**
     * @var array<string, string>
     */
    protected $casts = [
        'run_date' => 'date',
        'left_bv' => 'decimal:4',
        'right_bv' => 'decimal:4',
        'matched_bv' => 'decimal:4',
        'rate' => 'decimal:4',
        'gross_income' => 'decimal:2',
        'capping_deduction' => 'decimal:2',
        'net_income' => 'decimal:2',
    ];

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