app/Http/Resources/CartResource.php
/**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
Transform the resource into an array.
Transform the resource into an array .
public function toArray($request)
    {
        return [
            'product' => [
                'id' => $this->id,
                'name' => $this->name,
                'slug' => $this->slug,
                'description' => $this->description,
                'price' => $this->price,
                'image_path' => $this->image_path,
                'created_at' => $this->created_at,
                'updated_at' => $this->updated_at,
            ],
            'quantity' => $this->pivot->quantity
        ];
    }
public function toArray ( $ request ) { return [ 'product' => [ 'id' => $ this -> id , 'name' => $ this -> name , 'slug' => $ this -> slug , 'description' => $ this -> description , 'price' => $ this -> price , 'image_path' => $ this -> image_path , 'created_at' => $ this -> created_at , 'updated_at' => $ this -> updated_at , ] , 'quantity' => $ this -> pivot -> quantity ] ; }
Transform the resource into an array.
Transform the resource into an array .