Edit File: UserResource.php
<?php namespace App\Http\Resources; use Illuminate\Http\Resources\Json\JsonResource; use App\Traits\GeneralTrait; use App\Models\Country; use App\Http\Resources\CitiesResource; class UserResource extends JsonResource { use GeneralTrait; /** * Transform the resource into an array. * * @param \Illuminate\Http\Request $request * @return array */ public function toArray( $request ) { $country=Country::where("calling_code",$this->country_key)->first(); $flag= $country?($country->flag?$country->flagPath:''):''; return [ 'id' => $this->id, 'name' => $this->name??'', 'email' => $this->email??'', 'completed_info' => $this->completed_info == 'true'?true:false, 'show_policy' => $this->show_policy == 'true'?true:false, 'country_key' => $this->country_key??'', 'country_image'=>$flag, 'phone' => $this->fullPhone, 'changed_phone' => $this->changed_phone?$this->fullChangedPhone:'', 'avatar' => $this->avatarPath, 'lat' => (string)$this->lat??'', 'long' => (string)$this->long??'', 'address' => $this->address??'', 'rate' => $this->rate??'0.0', 'city' => $this->city ? new CitiesResource($this->city) : null, 'wallet' => ( string )$this->wallet??'0', 'num_orders' => ( string )$this->num_orders??'0', 'num_comments' => ( string )$this->num_comments??'0', 'acc_type' => $this->type??'user', 'new_orders_notify' => $this->new_orders_notify == 'true'?true:false, 'offers_notify' => $this->offers_notify == 'true'?true:false, 'time_zone' => date_default_timezone_get(), 'date' => date_format( date_create( $this->created_at ), 'Y-m-d' ) ]; } }
Back to File Manager