<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Relations\BelongsTo;

class LeaveBalance extends BaseModel
{
    protected $fillable = [
        'user_id',
        'leave_type_id',
        'total_allowance',
        'used',
        'remaining',
        'year',
    ];

    protected function casts(): array
    {
        return [
            'total_allowance' => 'integer',
            'used' => 'decimal:2',
            'remaining' => 'decimal:2',
            'year' => 'integer',
        ];
    }

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

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