<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use App\TransferProperty;
use Illuminate\Http\Request;
use DB;

class TransferPropertyHistory extends Model
{
    //
    protected $fillable = [
       'transfer_prop_id',"payment_head","inst_no","inst_track","due_date","due","received","balance","rcpt_no","ref_no","rcpt_date","rcpt_amount","late_days","surcharge"
    ];

  
    public function properties(){
        return $this->belongsTo('\App\TransferProperty','transfer_prop_id');
    }


    public function makeTransferHistory($property_id,$transfer_id){

  

        // DB::beginTransaction();
         
        // try {
          $customer_statements=  CustomerStatement::where('customer_property_id', $property_id)->get();
          
        //   dd($customer_statements,$transfer_id,TransferPropertyHistory::create(['transfer_prop_id'=>$transfer_id]));
       
          foreach($customer_statements as $cs){
            // dd($cs);
        // "rcpt_no" 
      
    TransferPropertyHistory::create(['transfer_prop_id'=>$transfer_id,"payment_head"=> $cs->payment_head,"inst_no"=> $cs->inst_no,"inst_track"=>$cs->inst_track,"due_date"=>$cs->due_date,"due"=>$cs->due,"received"=>$cs->received,"balance"=>$cs->balance,"rcpt_no"=>$cs->rcpt_no,"ref_no"=>$cs->ref_no,"rcpt_date"=>$cs->rcpt_date,"rcpt_amount"=>$cs->rcpt_amount,"late_days"=>$cs->late_days,"surcharge"=>$cs->surcharge]);
     }
    // dd('gfd');
        // } catch (\Exception $e) {
        //     DB::rollback();
        //     return false;
        // }
        // DB::commit();

    
        // return true;
    }
}

