<?php

namespace App\Http\Resources;


use Illuminate\Http\Resources\Json\JsonResource;
use DB;
use Auth;

class TicketsClientResources extends JsonResource
{
    public function toArray($request)
    {

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


        if($lang == 'ar'){

            $resName=$this->Responsible()->first()->Name;
            $UserName=$this->User()->first()->name;
        }else{
            $resName=$this->Responsible()->first()->NameEn;
            $UserName=$this->User()->first()->nameEn;

        }



        if ($lang == 'ar') {
            $data = [

                'id'=>$this->id,
                'code'=>$this->Code,
                'problem'=>$this->Problem,
                'bill_number'=>$this->Bill_Number,
                'responsible'=>$resName,
                'user'=>$UserName,

            ];

        }else{

            $data = [

                'id'=>$this->id,
                'code'=>$this->Code,
                'problem'=>$this->Problem,
                'bill_number'=>$this->Bill_Number,
                'responsible'=>$resName,
                'user'=>$UserName,


            ];

        }
        return $data ;
    }

}
