<?php

namespace App\Models;
use App\Enums\RecordStatusEnum;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Repayment extends BaseModel
{
    public $timestamps = false;
    use HasFactory;
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'repayments';
    protected $primaryKey='id';

    protected $fillable = [
        'invoice_id',
        'amount_to_pay',
        'discount',
        'amount_after_discount',
        'discount_type',
        'cash_repayment_amount',
        'bank_repayment_amount',
        'repayment_date',
        'payment_method',
        'bank_name',
        'transaction_ref',
        'notes',
        'lab_id',
        'exchange_rate',
        BaseModel::CREATED_AT_FIELD,
        BaseModel::CREATED_BY_FIELD,
        BaseModel::UPDATED_AT_FIELD,
        BaseModel::UPDATED_BY_FIELD,
        BaseModel::RECORD_STATUS_FIELD
    ];

    protected $hidden = [
        'lab_id',
        BaseModel::CREATED_AT_FIELD,
        BaseModel::CREATED_BY_FIELD,
        BaseModel::UPDATED_AT_FIELD,
        BaseModel::UPDATED_BY_FIELD,
        BaseModel::RECORD_STATUS_FIELD
    ];

    public static function boot()
    {
        parent::boot();
    }

    public function invoice(){
        return $this->belongsTo(Invoice::class, 'invoice_id','id');
    }

}
