<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Scopes\MessageScope;

class AvanseFinanceDetails extends Model
{

    protected $table = 'avanse_finance_detail';

    protected $fillable = [
        'finance_id','applicationNo', 'cif', 'finType', 'finCcy', 'finBranch', 'profitDaysBasis', 'finAmount', 'finAssetValue', 'downPayBank', 'downPaySupl', 'finRepayMethod', 'finStartDate', 'allowGrcPeriod', 'tdsApplicable', 'manualSchedule', 'planDeferCount', 'stepFinance', 'alwManualSteps', 'grcTerms', 'grcPeriodEndDate', 'grcRateBasis', 'grcPftRate', 'grcMargin', 'grcProfitDaysBasis', 'nextGrcPftRvwDate', 'nextGrcCpzDate', 'allowGrcRepay', 'grcSchdMthd', 'grcMinRate', 'grcMaxRate', 'grcMaxAmount', 'grcAdvPftRate', 'grcAdvMargin', 'numberOfTerms', 'reqRepayAmount', 'repayRateBasis', 'repayPftRate', 'repayMargin', 'scheduleMethod', 'repayFrq', 'nextRepayDate', 'repayPftFrq', 'nextRepayPftDate', 'repayRvwFrq', 'nextRepayRvwDate', 'nextRepayCpzDate', 'maturityDate', 'finRepayPftOnFrq', 'repayMinRate', 'repayMaxRate', 'repayAdvPftRate', 'repayAdvMargin', 'supplementRent', 'increasedCost', 'dsaCode', 'accountsOfficer', 'dmaCode', 'quickDisb', 'unPlanEMIHLockPeriod', 'unPlanEMICpz', 'reAgeCpz', 'maxUnplannedEmi', 'maxReAgeHolidays', 'alwBpiTreatment', 'dftBpiTreatment', 'planEMIHAlw', 'planEMIHMethod', 'planEMIHMaxPerYear', 'planEMIHMax', 'planEMIHLockPeriod', 'planEMICpz', 'grcAdvTerms', 'advTerms', 'advType', 'advStage', 'fixedRateTenor', 'fixedTenorRate', 'finCurrAssetValue', 'created_at'
    ];

    public function save(array $options = array())
    {
        $missingKeys = array_diff(array_values($this->fillable), array_keys($this->getAttributes()));
        foreach ($missingKeys as $missingKey){
            $this->$missingKey = '';
        }
        parent::save($options);
    }
}
