<?php

namespace App\Models;

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

class ChlVoucher extends Model
{
    use SoftDeletes;

    protected $table = 'chl_voucher';

    protected $primaryKey = 'CV_Id';

    protected $fillable = [
        'CV_Ty',
        'Ch_Date',
        'Ch_Start_Date',
        'Ch_End_Date',
        'CV_No',
        'Is_income',
        'TnT_Id',
        'Dpt_Id',
        'Bh_Id',
        'Lg_Id',
        'CV_Sr',
        'SL_Id',
        'SL_Nm',
        'Py_Mode',
        'PayMd_ID',
        'Amount',
        'FileNo',
        'Remarks',
        'Chq_Date',
        'IFSC_Code',
        'Bank_Name',
        'Acc_No',
        'Chq_No',
        'Is_Cheque_Verf',
        'Cheque_Cnl_Remark',
        'Chq_Status',
        'Rec_Date',
        'Total_Amount',
        'Net_Amount',
        'GST_No',
        'CHl_HOD',
        'CHL_HDT',
        'Status',
        'R_Status',
        'Status_Remark',
        'Penalty_Amount'

    ];
    // protected $attributes = [
    //     'Status' => 'draft'
    // ];

    public function tenderType()
    {
        return $this->belongsTo(\App\Models\TenderType::class, 'TnT_Id', 'TnT_ID');
        //                                         foreign key      owner key (must match TenderType primary key)
    }
    public function challanType()
    {
        return $this->belongsTo(\App\Models\ChallanType::class, 'CV_Ty', 'Cht_Id');
    }

    public function department()
    {
        return $this->belongsTo(\App\Models\Department::class, 'Dpt_Id', 'Dpt_id');
    }

    public function budgetHead()
    {
        return $this->belongsTo(\App\Models\BudgetHead::class, 'Bh_Id', 'Bh_Id');
    }

    public function ledger()
    {
        return $this->belongsTo(\App\Models\LedgerMaster::class, 'Lg_Id', 'Lg_Id');
    }

    public function subLedger()
    {
        return $this->belongsTo(\App\Models\SubLedgerMaster::class, 'SL_Id', 'SL_Id');
    }

    public function hod()
    {
        return $this->belongsTo(UserMaster::class, 'CHl_HOD', 'Usr_Id');
    }

    public function statusMaster()
    {
        return $this->belongsTo(\App\Models\ActionMaster::class, 'Status', 'Act_Id');
    }


     public function RStatus()
    {
        return $this->belongsTo(\App\Models\ActionMaster::class, 'R_Status', 'Act_Id');
    }

    public function chequeStatus()
    {
        return $this->belongsTo(\App\Models\ActionMaster::class, 'Chq_Status', 'Act_Id');
    }

    public function payModes()
    {
        return $this->belongsTo(\App\Models\PaymentMode::class, 'PayMd_ID', 'PayMd_ID');
    }

    public function payDetails()
    {
        return $this->hasMany(PayDetail::class, 'CV_Id', 'CV_Id');
    }
}
