Product One
-Fresh and elegant.
+{{ $perfume['name'] }}
++ {{ $perfume['concentration_label'] }}
+Product Two
-Woody & classic.
-diff --git a/app/Livewire/Home/Index.php b/app/Livewire/Home/Index.php index bcb5cd5..e016779 100644 --- a/app/Livewire/Home/Index.php +++ b/app/Livewire/Home/Index.php @@ -6,7 +6,9 @@ use App\Models\ChooseUs; use App\Models\Customer; use App\Models\Faq; +use App\Models\Perfume; use App\Models\PerfumeFeature; +use App\Models\Testimonial; use Illuminate\Contracts\View\View; use Illuminate\Http\RedirectResponse; use Illuminate\Support\Facades\Storage; @@ -30,6 +32,8 @@ class Index extends Component public $latestMembers = []; + public array $testimonials = []; + public function mount(): void { $this->brands = Brand::orderBy('sort_order') @@ -70,6 +74,30 @@ public function mount(): void ->inRandomOrder() ->take(3) ->get(); + + $this->testimonials = Testimonial::with(['user', 'user.customer']) + ->show() + ->latest() + ->take(5) + ->get() + ->toArray(); + + $this->bestSellingPerfumes = Perfume::withSum(['items' => function ($query) { + $query->whereHas('order', function ($q) { + $q->paid(); + }); + }], 'quantity') + ->orderByDesc('items_sum_quantity') + ->take(2) + ->get() + ->map(function (Perfume $perfume) { + $perfume->image = $perfume->getFirstMediaUrl('image') ? Storage::url($perfume->getFirstMediaUrl('image')) : asset('assets/images/logo.png'); + $perfume->concentration_label = $perfume->concentration->label(); + + return $perfume; + }) + ->filter(fn (Perfume $perfume) => $perfume->items_sum_quantity > 0) + ->toArray(); } public function render(): View @@ -88,4 +116,6 @@ public function goToVoucher(): RedirectResponse { return redirect('/voucher'); } + + public $bestSellingPerfumes = []; } diff --git a/resources/views/livewire/home/partials/jumbotron/left.blade.php b/resources/views/livewire/home/partials/jumbotron/left.blade.php index f80295e..b0fe58d 100644 --- a/resources/views/livewire/home/partials/jumbotron/left.blade.php +++ b/resources/views/livewire/home/partials/jumbotron/left.blade.php @@ -20,26 +20,30 @@ class="border-2 border-home-background w-8 h-8 lg:w-10 lg:h-10 rounded-full over @endif
- Selecting a perfume is a personal journey. Consider your lifestyle, favorite scents, and the impression you - want - to make. + Setiap parfum punya cerita. Pilih aroma yang sesuai dengan gaya hidupmu dan kesan yang ingin kamu tampilkan.
Fresh and elegant.
++ {{ $perfume['concentration_label'] }}
+Woody & classic.
-