fixed category and product route

This commit is contained in:
Edward Yang 2022-06-27 20:01:13 +08:00
parent fea082bb0b
commit af91641ae4
3 changed files with 7 additions and 4 deletions

View File

@ -18,7 +18,7 @@ class CategoryList extends JsonResource
$item = [
'id' => $this->id,
'name' => $this->description->name ?? '',
// 'url' => url()->route('shop.categories.show', ['category' => $this])
'url' => shop_route('categories.show', ['category' => $this])
];
if ($this->relationLoaded('children') && $this->children->count() > 0) {

View File

@ -20,7 +20,7 @@ class ProductList extends JsonResource
return [
'id' => $this->id,
'name' => $this->description->name ?? '',
'url' => url()->route('shop.products.show', ['product' => $this]),
'url' => shop_route('products.show', ['product' => $this]),
'price' => $this->price,
'image' => image_resize($this->image),
'price_format' => currency_format($this->price),

View File

@ -23,8 +23,11 @@ class ShopServiceProvider extends ServiceProvider
$this->loadRoutesFrom(__DIR__ . '/../Routes/shop.php');
$this->mergeConfigFrom(__DIR__ . '/../../Config/beike.php', 'beike');
$this->loadSettings();
$this->loadShareView();
$this->registerGuard();
$this->app->booted(function () {
$this->loadShareView();
});
}
protected function loadSettings()
@ -49,7 +52,7 @@ class ShopServiceProvider extends ServiceProvider
protected function registerGuard()
{
Config::set('auth.guards.'.Customer::AUTH_GUARD, [
Config::set('auth.guards.' . Customer::AUTH_GUARD, [
'driver' => 'session',
'provider' => 'shop_customer',
]);