<?php

namespace App\Http\Resources\ECom;


use App\Models\Coins;
use App\Models\Customers;
use App\Models\Employess;
use App\Models\GeneralDaily;
use App\Models\ProductSalesOrder;
use App\Models\ReciptVoucherDetails;
use App\Models\ReturnSales;
use Illuminate\Http\Resources\Json\JsonResource;
use DB;
use Auth;
use DateTime;

class ProductsMyOrdersResources extends JsonResource
{


    public function toArray($request)
    {


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


            if($lang == 'ar'){
                $proName=$this->P_Ar_Name;

                if(!empty($this->V1)){
                    $proVName=$this->V1()->first()->Name;
                }else{

                    $proVName='';
                }


                if(!empty($this->V2)){
                    $proVVName=$this->V2()->first()->Name;
                }else{

                    $proVVName='';
                }


            }else{

                $proName=$this->P_En_Name;

                if(!empty($this->V1)){
                    $proVName=$this->V1()->first()->NameEn;
                }else{

                    $proVName='';
                }


                if(!empty($this->V2)){
                    $proVVName=$this->V2()->first()->NameEn;
                }else{

                    $proVVName='';
                }


            }




        $data=[

            'image'=>URL::to($this->Image),
            'product_name'=>$proName . $proVName . $proVVName,
            'qty'=>$this->Qty,
            'price'=>$this->Price,
            'total'=>$this->Total,

        ];



        return $data ;
    }

}
