<?php

namespace App\Http\Resources\Reports\CRM;


use App\Models\CommentsClients;
use App\Models\Customers;
use App\Models\Sales;
use Illuminate\Http\Resources\Json\JsonResource;
use DB;
use Auth;
use DateTime;
class CommentsClientsResources extends JsonResource
{


    public function toArray($request)
    {


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


        if (!empty($this->Responsible()->first()->Name)) {

           if($lang == 'ar') {

               $res=$this->Responsible()->first()->Name;
           }else {

               $res=$this->Responsible()->first()->NameEn;
           }

    }else{
            $res='';
        }


        if (!empty($this->Responsible()->first()->Name)) {

            if($lang == 'ar') {

                $res=$this->Responsible()->first()->Name;
            }else {

                $res=$this->Responsible()->first()->NameEn;
            }

        }else{
            $res='';
        }


        if (!empty($this->Rate()->first()->Arabic_Name)) {

            if($lang == 'ar') {

                $rate=$this->Rate()->first()->Arabic_Name;
            }else {

                $rate=$this->Rate()->first()->English_Name;
            }

        }else{
            $rate='';
        }



        if (!empty($this->Type()->first()->Arabic_Name)) {

            if($lang == 'ar') {

                $type=$this->Type()->first()->Arabic_Name;
            }else {

                $type=$this->Type()->first()->English_Name;
            }

        }else{
            $type='';
        }






        $data=[

            'Code'=>$this->Code
            ,'Date'=>$this->Date
            ,'Time'=>$this->Time
            ,'Comment'=>$this->Comment
            ,'Responsible'=>$res
            ,'Rate_Interview'=>$rate
            ,'Visit_Cost'=>$this->Visit_Cost
            ,'Note'=>$this->Note
            ,'Interview_Type'=>$type

        ];




        return $data ;
    }

}
