<?php

namespace App\Http\Resources\Reports\Accounting;


use App\Models\Employess;
use App\Models\PaymentVoucherDetails;
use Illuminate\Http\Resources\Json\JsonResource;
use DB;
use Auth;


class ExpensesReportFilterApiResources extends JsonResource
{


    public function toArray($request)
    {

        $lang = $request->header('lang', '');


        $VVVVV=PaymentVoucherDetails::where('PV_ID',$this->id)->first();


        if($lang == 'ar' ){

            if(!empty($VVVVV->Account)){
                $xName=$VVVVV->Account()->first()->Name;
            }else{
                $xName='';
            }


        }else{

            if(!empty($VVVVV->Account)){
                $xName=$VVVVV->Account()->first()->NameEn;
            }else{
                $xName='';
            }


        }

        $data=[

            'code'=>$this->Code
            ,'name'=>$xName
            ,'total_debaitor'=>$this->Total_Debaitor

        ];




        return $data ;
    }

}
