diff --git a/app/Livewire/Home/Index.php b/app/Livewire/Home/Index.php
index e016779..f24edd4 100644
--- a/app/Livewire/Home/Index.php
+++ b/app/Livewire/Home/Index.php
@@ -38,10 +38,11 @@ public function mount(): void
{
$this->brands = Brand::orderBy('sort_order')
->get()
- ->map(fn (Brand $brand) => [
- 'name' => $brand->name,
- 'image' => $brand->getFirstMediaUrl('image') ? Storage::url($brand->getFirstMediaUrl('image')) : asset('assets/images/logo.png'),
- ])
+ ->map(function (Brand $brand) {
+ $brand->image = $brand->getFirstMediaUrl('image') ? $brand->getFirstMediaUrl('image') : asset('assets/images/dark-logo.png');
+
+ return $brand;
+ })
->toArray();
$this->perfumeFeatures = PerfumeFeature::orderBy('sort_order')
diff --git a/app/Livewire/Home/Product/Index.php b/app/Livewire/Home/Product/Index.php
index 4c4ba84..b568841 100644
--- a/app/Livewire/Home/Product/Index.php
+++ b/app/Livewire/Home/Product/Index.php
@@ -2,33 +2,65 @@
namespace App\Livewire\Home\Product;
+use App\Models\Perfume;
use Illuminate\Contracts\View\View;
use Livewire\Attributes\Layout;
use Livewire\Component;
+use Livewire\WithPagination;
#[Layout('components.layouts.home', [
- 'title' => 'Product',
+ 'title' => 'Produk',
])]
class Index extends Component
{
- public bool $isDetail = false;
+ use WithPagination;
- public ?string $slug = null;
+ public string $productType = 'perfume';
- public function mount(?string $slug = null): void
+ public array $recommendations = [];
+
+ public function mount(): void
{
- if ($slug) {
- $this->isDetail = true;
- $this->slug = $slug;
- }
+ $this->recommendations = Perfume::with(['brand', 'categories', 'items'])
+ ->withCount('items')
+ ->orderBy('items_count', 'desc')
+ ->take(5)
+ ->get()
+ ->map(function ($perfume) {
+ return [
+ 'id' => $perfume->id,
+ 'name' => $perfume->name,
+ 'category' => $perfume->categories->first()?->name,
+ 'price' => $perfume->sale_price,
+ 'image' => $perfume->getFirstMediaUrl() ?: 'https://placehold.co/400x500/png?text='.urlencode($perfume->name),
+ 'rating' => 4.5,
+ ];
+ })
+ ->toArray();
}
public function render(): View
{
- return view(
- $this->isDetail
- ? 'livewire.home.product.show'
- : 'livewire.home.product.index'
- );
+ $perfumes = Perfume::with(['brand', 'categories', 'items'])
+ ->latest()
+ ->paginate(9)
+ ->through(function ($perfume) {
+ return [
+ 'id' => $perfume->id,
+ 'name' => $perfume->name,
+ 'category' => $perfume->categories->first()?->name,
+ 'price' => $perfume->sale_price,
+ 'image' => $perfume->getFirstMediaUrl() ?: 'https://placehold.co/400x500/png?text='.urlencode($perfume->name),
+ 'rating' => 4.5,
+ 'reviews' => $perfume->items->count(),
+ 'is_new' => $perfume->created_at->diffInDays(now()) <= 30,
+ 'colors' => ['#78350f', '#1f2937'],
+ ];
+ });
+
+ return view('livewire.home.product.index', [
+ 'pageTitle' => 'Produk',
+ 'perfumes' => $perfumes,
+ ]);
}
}
diff --git a/app/Providers/ViewServiceProvider.php b/app/Providers/ViewServiceProvider.php
index 817ddd4..6338073 100644
--- a/app/Providers/ViewServiceProvider.php
+++ b/app/Providers/ViewServiceProvider.php
@@ -305,25 +305,9 @@ public function boot(): void
],
[
'title' => 'Produk',
- 'type' => 'dropdown',
- 'action' => 'goToProduct',
- 'items' => [
- [
- 'title' => 'Parfum',
- 'route' => 'product.perfume.index',
- 'match' => 'product.perfume.*',
- ],
- [
- 'title' => 'Botol',
- 'route' => 'product.bottle.index',
- 'match' => 'product.bottle.*',
- ],
- [
- 'title' => 'Arabian',
- 'route' => 'product.arabian.index',
- 'match' => 'product.arabian.*',
- ],
- ],
+ 'type' => 'link',
+ 'route' => 'product.index',
+ 'match' => 'product.*',
],
[
'title' => 'Voucher',
diff --git a/resources/views/components/sections/ui/home/_header.blade.php b/resources/views/components/sections/ui/home/_header.blade.php
index 6672dc0..2285e46 100644
--- a/resources/views/components/sections/ui/home/_header.blade.php
+++ b/resources/views/components/sections/ui/home/_header.blade.php
@@ -19,7 +19,7 @@ class="size-6 text-white hidden transition-transform duration-300">
-
+
@@ -38,8 +38,8 @@ class="{{ request()->routeIs($item['route']) ? 'font-bold text-home-primary' : '
@if ($item['type'] === 'dropdown')