<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class LeaveTrans extends Model
{
    use SoftDeletes;

    protected $table = 'Leave_Trans';
    protected $primaryKey = 'LTr_id';

    protected $fillable = [
        'LT_id',
        'Emp_Id',
        'FY_Id',
        'Tr_Type',
        'Tr_Days',
        'Paid',
        'UnPaid',
        'Tr_Mode',
        'LT_Date', 
        'Tr_Date',
        'Status'
    ];

    protected $casts = [
        'Paid' => 'decimal:2',
        'UnPaid' => 'decimal:2',
        'LT_Date' => 'date',   // ✅ Optional but recommended
        'Tr_Date' => 'date',   // ✅ Optional but recommended
    ];

    protected $dates = ['deleted_at'];

    public function leaveType()
    {
        return $this->belongsTo(LeaveTypeMaster::class, 'LT_id', 'LT_id');
    }

    public function employee()
    {
        return $this->belongsTo(EmployeeMaster::class, 'Emp_Id', 'Emp_Id');
    }

    public function financialYear()
    {
        return $this->belongsTo(FyearMaster::class, 'FY_Id', 'FY_Id');
    }
    
     public function statusAction()
    {
        return $this->belongsTo(ActionMaster::class, 'Status', 'Act_Id');
    }
}
