From 1b07e010f83c44d89c1d9ad367c62e72a38b01b7 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Thu, 23 Jun 2022 16:28:51 +0800 Subject: [PATCH] fixed url for category and product --- beike/Shop/Http/Resources/CategoryList.php | 1 + beike/Shop/Http/Resources/ProductList.php | 1 + 2 files changed, 2 insertions(+) diff --git a/beike/Shop/Http/Resources/CategoryList.php b/beike/Shop/Http/Resources/CategoryList.php index a4fc4e06..948dda6a 100644 --- a/beike/Shop/Http/Resources/CategoryList.php +++ b/beike/Shop/Http/Resources/CategoryList.php @@ -18,6 +18,7 @@ class CategoryList extends JsonResource $item = [ 'id' => $this->id, 'name' => $this->description->name ?? '', + 'url' => url()->route('shop.categories.show', ['category' => $this]) ]; if ($this->relationLoaded('children') && $this->children->count() > 0) { diff --git a/beike/Shop/Http/Resources/ProductList.php b/beike/Shop/Http/Resources/ProductList.php index d1eef3aa..1c645ab0 100644 --- a/beike/Shop/Http/Resources/ProductList.php +++ b/beike/Shop/Http/Resources/ProductList.php @@ -20,6 +20,7 @@ class ProductList extends JsonResource return [ 'id' => $this->id, 'name' => $this->description->name ?? '', + 'url' => url()->route('shop.products.show', ['product' => $this]), 'price' => $this->price, 'image' => image_resize($this->image), 'price_format' => currency_format($this->price),