Edit File: StoreProfileResource.php
<?php namespace App\Http\Resources; use App\Models\Category; use App\Models\Country; use App\Models\Setting; use App\Services\SettingService; use Illuminate\Http\Resources\Json\JsonResource; class StoreProfileResource extends JsonResource { public function toArray($request) { $lang = $request->header('lang') ?? 'ar'; $setting = SettingService::appInformations(Setting::pluck('value', 'key')); $slug = ($this->store ? $this->store->slug : $this->category); $category = Category::where('slug', $slug)->first(); $subcategories = ($this->store ? $this->store->subcategories()->get() : $this->subcategories()->get()); $data = 'done'; if ($this->user->completed_info == 'false' && $this->timings()->count() == 0){ $data = 'times'; }elseif ($this->user->completed_info == 'false' && $this->timings()->count() > 0){ $data = 'store_details'; } $country = Country::where('calling_code', $this->user->country_key)->first(); return [ 'id' => $this->id, 'category_name' => $category ? $category->name : '', 'is_open' => $this->openingHours($lang)['open_status'], 'view_in_ui_only' => $setting['view_in_ui_only'] == 'false' ? false : true, 'complete_data' => $data , 'name_ar' => $this->getTranslation('name', 'ar'), 'name_en' => $this->getTranslation('name', 'en'), 'name' => $this->user->name, 'icon' => $this->store ? ($this->store->icon ? $this->store->iconPath : '' ) : ($this->icon ? $this->iconPath : '' ), 'lat' => (string) $this->lat ?? '', 'long' => (string) $this->long ?? '', 'address' => $this->address ?? '', 'num_rating' => $this->num_rating ?? 0, 'rate' => $this->rate ? number_format($this->rate, 1) : '0.0', 'rate_num' => (string) $this->num_rating ?? '0', 'category' => (string) $this->category ?? '', 'iban_number' => $this->store ? $this->store->iban_number :( $this->iban_number ?? ''), 'bank_number' => $this->store ? $this->store->bank_number :( $this->bank_number ?? ''), 'bank_owner_name' => $this->store ? $this->store->bank_owner_name :( $this->bank_owner_name ?? ''), 'bank_name' => $this->store ? $this->store->bank_name :( $this->bank_name ?? ''), 'available' => (string) $this->available == 'true' ? true : false, 'has_contract' => ((string) $this->has_contract == 'true' || (string) $this->has_contract == '1') ? true : false, 'distance' => (number_format((float) $this->distance, 2, '.', '') ?? '0.00') . ' ' . trans('stores.km'), 'opening_hours' => $this->storeOpeningHours(), 'categories' => CategoriesResource::collection($subcategories), 'branch_country_key' => $this->user->country_key, 'branch_phone' => $this->user->phone, 'branch_email' => $this->user->email, 'phone' => $this->user->phone, 'country_key' => $this->user->country_key, 'user_name_en' => $this->user->name_en, 'country_flag' => $country ? $country->flag_path : '', 'new_orders_notify' => $this->user->new_orders_notify=='true'?true:false, 'offers_notify' => $this->user->offers_notify=='true'?true:false, 'sound_notify' => ($this->user->notify_sound == 'true')? true : false, ]; } }
Back to File Manager