<?php

namespace App\Http\Resources;


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

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

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


        if($lang == 'ar'){
            $type=$this->Type()->first()->Arabic_Name;



        }else{

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

        }


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


                'id'=>$this->id,
                'code'=>$this->Code,
                'date'=>$this->Date,
                'month'=>$this->Month,
                'number_of_days'=>$this->Num_of_Days,
                'start_date'=>$this->Start_Date,
                'discount'=>$this->Discount,
                'note'=>$this->Note,
                'type'=>$type,



            ];
        }else{


            $data = [

                'id'=>$this->id,
                'code'=>$this->Code,
                'date'=>$this->Date,
                'month'=>$this->Month,
                'number_of_days'=>$this->Num_of_Days,
                'start_date'=>$this->Start_Date,
                'discount'=>$this->Discount,
                'note'=>$this->Note,
                'type'=>$type,


            ];
        }



        return $data ;
    }

}
