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

- Discover your best
perfume at today + Temukan
+ + signature scent-mu + hari ini

- 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.

- + Jelajahi Toko +
- @include('livewire.home.partials.jumbotron.testimonial') diff --git a/resources/views/livewire/home/partials/jumbotron/right.blade.php b/resources/views/livewire/home/partials/jumbotron/right.blade.php index d0f574c..5f8641f 100644 --- a/resources/views/livewire/home/partials/jumbotron/right.blade.php +++ b/resources/views/livewire/home/partials/jumbotron/right.blade.php @@ -3,74 +3,47 @@ class="relative w-full lg:w-[65%] min-h-[600px] lg:min-h-screen hidden lg:flex f
-
+
+
-
+
-
+ @foreach ($bestSellingPerfumes as $perfume) +
-
- Product One -
+
+ {{ $perfume['name'] }} +
-
-
-

Product One

-

Fresh and elegant.

+
+
+

{{ $perfume['name'] }}

+

+ {{ $perfume['concentration_label'] }}

+
+ +
+ + +
- -
- - -
-
-
- -
- -
- Product One -
- -
-
-

Product Two

-

Woody & classic.

-
- -
- - -
-
-
+
+ @endforeach
diff --git a/resources/views/livewire/home/partials/jumbotron/testimonial.blade.php b/resources/views/livewire/home/partials/jumbotron/testimonial.blade.php index a031f16..a4d5e25 100644 --- a/resources/views/livewire/home/partials/jumbotron/testimonial.blade.php +++ b/resources/views/livewire/home/partials/jumbotron/testimonial.blade.php @@ -1,115 +1,85 @@ -
+
+ @if (!empty($testimonials)) +
-
- -
-
- -
-

Sarah Jenkins

-
★★★★★
-
+
+ @foreach ($testimonials as $index => $testimonial) +
+
+ {{ $testimonial['user']['customer']['name'] }} +
+

+ {{ $testimonial['user']['customer']['name'] }}

+
+ @for ($i = 0; $i < $testimonial['rating']; $i++) + ★ + @endfor +
+
+
+

+ "{{ $testimonial['content'] }}" +

+
+ @endforeach
-

"Aroma yang sangat elegan dan - tahan lama. Saya sangat menyukainya untuk dipakai sehari-hari ke kantor."

-
-
-
- -
-

Michael Chen

-
★★★★★
-
+
+ +
-

"Pengiriman sangat cepat dan - packaging aman. Wanginya persis seperti deskripsi di website."

-
- -
-
- -
-

Jessica Tan

-
★★★★★
-
-
-

"Varian Product Two adalah - favorit saya! Sangat fresh dan tidak menyengat. Recommended!"

-
- -
- -
- - -
- -
- - +
+ @endif +