Edit File: ProductDetailsResource.php
<?php namespace App\Http\Resources\Api\Provider; use App\Http\Resources\Api\General\Settings\BasicCategoryResource; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; use JsonSerializable; class ProductDetailsResource extends JsonResource { /** * Transform the resource into an array. * * @param Request $request * @return array|Arrayable|JsonSerializable */ public function toArray($request) { return [ 'id' => $this?->id, 'name' => $this?->name, 'has_price' => $this?->has_price, 'images' => ProductImageResource::collection($this->productImages), 'price' => newNumberFormat($this?->price), 'price_after_discount' => newNumberFormat($this?->price_after_discount), 'description' => $this?->description, 'translated_names' => $this?->getTranslations('name'), 'translated_descriptions' => $this?->getTranslations('description'), 'main_category' => BasicCategoryResource::make($this->category->parent), 'category' => BasicCategoryResource::make($this->category), 'classifications' => ProductClassificationResource::collection($this->productClassifications), ]; } }
Back to File Manager