0, 'slug' => '', 'name' => '', 'description' => '', 'price' => 0, 'discountedPriceHt' => 0, 'picture' => '', 'orderable_start' => '', 'orderable_end' => '' ]; /** * ProductResource * * @param \App\Models\Product $product */ public function __construct(Product $product) { $this->product = $product; } /** * Transform the resource into an array. * * @param \Illuminate\Http\Request|null $request * @return array * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ public function toArray($request = null) { // @phpcs:enable $data = array_merge( \array_intersect_key( $this->product->toArray(), self::$skeleton ), ['discountedPriceHt' => $this->product->discountedPriceHt], [ 'nutriscore' => (isset($this->product->foodProduct->nutriscore)) ? $this->product->foodProduct->nutriscore : null ] ); $data['description'] = clean($data['description']); return $data; } }