Edit File: GooglePlacesResource.php
<?php namespace App\Http\Resources; use Illuminate\Http\Resources\Json\JsonResource; use App\Traits\ApiTrait; use App\Traits\GeneralTrait; use App\Services\OrderService; class GooglePlacesResource extends JsonResource { use GeneralTrait, ApiTrait; /** * Transform the resource into an array. * * @param \Illuminate\Http\Request $request * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable */ public function toArray($request) { // $days = []; $timimng = []; if(isset($this->current_opening_hours->weekday_text)) { foreach($this->current_opening_hours->weekday_text as $name) { $splitName = explode(' ', $name, 2); $timimng [] = ['day' => $splitName[0] , 'time' => $splitName[1]]; } // dd($timimng); $arr = json_encode($this->current_opening_hours->weekday_text); $days=json_decode($arr); // sort($days); } // dd($days); $order_service = (new OrderService()); $distance = '0'; $distance = $this->distance ?? ''; // dd($this); // empty($this->distance) if($request->lat && $request->long && empty($distance)) { $distance = $order_service->getdirectDistance((isset($this->id) ? $this->lat : (string)$this->geometry->location->lat), (isset($this->id) ? $this->long : (string)$this->geometry->location->lng), $request->lat, $request->long); } return [ 'id' => 0, 'place_id' => $this->place_id??'', 'category_name' => $this->business_status??'', 'is_open' => $this->current_opening_hours->open_now == 'true' ? true : false, 'delivery_price' => $this->deliveryPrice($distance)['display_delivery_price'] . ' ' . trans('stores.sar'), 'name' => $this->name ?? '', 'icon' => asset('assets/uploads/settings/google_store.png') ?? '', 'cover' => asset('assets/uploads/stores/cover.png') ?? '', 'lat' => (string)$this->geometry->location->lat ?? '', 'long' => (string)$this->geometry->location->lng ?? '', 'address' => ($this->address?? $this->vicinity) ?? '', 'num_rating' => $this->num_rating ?? 0, 'rate' => isset($this->rating) ? (string)$this->rating : '0.0', 'category' => $this->category ?? '', 'offer' => false, 'offer_image' => '', 'offer_amount' => '0', 'offer_type' => '', 'offer_max' => '', 'available' => true , 'has_contract' => false, 'distance' => '0.0' . ' ' . trans('stores.km'), 'opening_hours' => $timimng ?? [], 'memu' => [], 'menu_images' => [], ]; } }
Back to File Manager