Edit File: UserResource.php
<?php namespace App\Http\Resources; use App\Http\Requests\Admin\fqs\store; use App\Models\City; use App\Traits\GeneralTrait; use Illuminate\Http\Resources\Json\JsonResource; class UserResource extends JsonResource { use GeneralTrait; /** * Transform the resource into an array. * * @param \Illuminate\Http\Request $request * @return array */ public function toArray($request) { $rate = $this->rate ?? '0.0'; return [ 'id' => $this->id, 'name' => $this->name ?? '', 'email' => $this->email ?? '', 'completed_info' => $this->completed_info == 'true' ? true : false, 'country_key' => $this->country_key ?? '', 'phone' => $this->phone, 'changed_phone' => $this->changed_phone ? $this->fullChangedPhone : '', 'avatar' => $this->avatarPath ?? '', 'lat' => $this->lat ?? '', 'long' => $this->long ?? '', 'address' => $this->address ?? '', 'rate' => $rate, 'wallet' => (string) $this->wallet ?? '0', 'total_bills' => (string) $this->total_bills ?? '0', 'total_delivery_fees' => (string) $this->total_delivery_fees ?? '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'), 'gender' => $this->gender, 'nationality_id' => (int) $this->nationality_id ?? 0, 'city_id' => (int) $this->city_id ?? 0, 'nationality_name' => $this->nationality->name ?? '', 'city_name' => $this->city->name ?? '', 'qualification_id' => (int)$this->qualification_id ?? 0, 'qualification_name' => $this->qualification->name ?? '', 'id_number' => $this->id_number ?? '', 'commission_used' => $this->store ? $this->store->commission_used : '', ]; } }
Back to File Manager