Edit File: ProductResource.php
<?php namespace App\Http\Resources\Api\Provider; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; use Illuminate\Support\Facades\Route; use JsonSerializable; class ProductResource extends JsonResource { /** * Transform the resource into an array. * * @param Request $request * @return array|Arrayable|JsonSerializable */ public function toArray($request) { $routeShow = Route::currentRouteName() == 'provider.products.show'; return [ 'id' => $this?->id, 'name' => $this?->name, 'has_price' => $this?->has_price, 'has_price_text' => $this?->has_price_text, 'images' => ProductImageResource::collection($this->productImages), 'description' => $this?->description, ]; } }
Back to File Manager