<?php

namespace App;

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

class PreEligibilityCreditReport extends Model
{
    use Encryptable;

    protected $table = 'pre_eligibility_credit_report';

    public static $encryptable = [
        'PANIdsList',
        'VoterID',
        'NationalIdsList',
        'panValidation',
    ];

    protected static function boot()
    {
        parent::boot();
        static::addGlobalScope(new MessageScope(static::$encryptable));
    }

    protected $fillable = [
        'application_id',
        'Score',
        'NoOfActiveAccounts',
        'activeCreditCardLimit',
        'sanctionAmount',
        'TotalPastDue',
        'Past12Months',
        'Past24Months',
        'TotalEnquiry',
        'zeroBalanceAccount',
        'pastDueAccount',
        'finalCategory',
        'VoterID',
        'contactInfoList',
        'PANIdsList',
        'AddressInfoList',
        'applicant_type',
        'deleted_at',
        'created_at',
        'updated_at',
        'NationalIdsList',
        'DateOfBirth',
        'panValidation',
        'ml_loan_amount',
        'ml_eligible_emi_amount',
        'foir_loan_amount',
        'foir_eligible_emi_amount',
        'foirNAIncludingCFEMI',
        'foirIncludingCFEMI',
        'cfFoir',
        'bureau',
        'panVendor',
        'bureau_type',
        'max_emi_serviced',
        'current_emi_sum',
    ];

    public function application()
    {
        return $this->hasOne('App\PreEligibilityApplication', 'id', 'application_id');
    }

    public function incompleteFoir()
    {
        return $this->hasOne('App\PreEligibilityFoir', 'application_id', 'application_id')
            ->where('installmentAmount', 0);
    }
}
