Skip to content

Commit

Permalink
fix: set resource when rendering public index
Browse files Browse the repository at this point in the history
  • Loading branch information
phojie committed Jan 5, 2023
1 parent a820e9b commit d49b3f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions app/Http/Controllers/PublicController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace App\Http\Controllers;

use App\Http\Resources\CategoryResource;
use App\Http\Resources\ProductResource;
use App\Models\Category;
use App\Models\Product;
use Inertia\Inertia;
Expand All @@ -22,8 +24,8 @@ public function index()
->get();

return Inertia::render('Index', [
'categories' => $randomCategories,
'products' => $trendingProducts,
'categories' => CategoryResource::collection($randomCategories),
'products' => ProductResource::collection($trendingProducts),
]);
}
}
4 changes: 2 additions & 2 deletions resources/js/pages/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ const perks = [

<div class="grid grid-cols-2 mt-6 gap-x-4 gap-y-10 sm:gap-x-6 md:grid-cols-4 md:gap-y-0 lg:gap-x-8">
<AppProductCard
v-for="product in products" :key="product.id"
v-for="product in products"
:key="product.id"
:name="product.name"
:image="product.image as string"
:description="product.description"
:variants="product.variants as Array<Variant>"
:slug="product.slug as string"
:product="product"
/>
</div>

Expand Down

0 comments on commit d49b3f6

Please sign in to comment.