From 2ab0549f02b18da07bf5300dfa3baef9ee7f30c8 Mon Sep 17 00:00:00 2001 From: bayu Date: Wed, 31 Dec 2025 13:14:30 +0700 Subject: [PATCH] add new arrivals --- app/Models/Items.php | 35 +++--- app/View/Components/Home/NewArrivals.php | 28 +++++ .../components/home/new-arrivals.blade.php | 97 +++++++++++++++ resources/views/home/fashion-v1.blade.php | 114 +----------------- 4 files changed, 146 insertions(+), 128 deletions(-) create mode 100644 app/View/Components/Home/NewArrivals.php create mode 100644 resources/views/components/home/new-arrivals.blade.php diff --git a/app/Models/Items.php b/app/Models/Items.php index c96f0c2..8948930 100644 --- a/app/Models/Items.php +++ b/app/Models/Items.php @@ -238,26 +238,31 @@ class Items extends Model }); - return $this->hasOne(Discount::class,DB::raw("item_reference.item_id")) - ->leftJoin("discount_items","discounts.id","=","discount_id") - ->leftJoin("item_reference","item_reference.id","=","item_reference_id") - ->where("discounts.type","price") - ->orderBy("discounts.created_at","desc") + return $this->hasOne(Discount::class, 'id', 'item_reference_id') + ->leftJoin('discount_items', 'discount_items.discount_id', '=', 'discounts.id') + ->where('discounts.type', 'price') ->where(function ($query) { - $query->whereNull("valid_at") - ->orWhereDate("valid_at", "<=", Carbon::now()); + $query->where('valid_at', '<=', now()) + ->orWhereNull('valid_at'); }) ->where(function ($query) { - $query->whereNull("expired_at") - ->orWhereDate("expired_at", ">=", Carbon::now()); + $query->where('expired_at', '>', now()) + ->orWhereNull('expired_at'); }) - ->where(function($query) use ($location_id, $is_consignment){ - if (!$is_consignment) - $query->whereNull("discounts.location_id"); - if ($location_id) - $query->orWhere("discounts.location_id", $location_id); + ->where(function ($query) use ($location_id, $is_consignment) { + if (!$is_consignment) { + $query->whereNull('discounts.location_id'); + } + + if ($location_id) { + $query->orWhere('discounts.location_id', $location_id); + } }) - ->select("item_id","price"); + ->orderByDesc('discounts.created_at') + ->select([ + 'discount_items.item_reference_id', + 'discount_items.price', + ]); } public function stock() diff --git a/app/View/Components/Home/NewArrivals.php b/app/View/Components/Home/NewArrivals.php new file mode 100644 index 0000000..e369d19 --- /dev/null +++ b/app/View/Components/Home/NewArrivals.php @@ -0,0 +1,28 @@ + 'new', + ]; + $this->products = $productRepository->getList($params); + } + + /** + * Get the view/contents that represent the component. + */ + public function render(): View + { + return view('components.home.new-arrivals'); + } +} diff --git a/resources/views/components/home/new-arrivals.blade.php b/resources/views/components/home/new-arrivals.blade.php new file mode 100644 index 0000000..690f077 --- /dev/null +++ b/resources/views/components/home/new-arrivals.blade.php @@ -0,0 +1,97 @@ + +
+
+

New arrivals

+

Meet the {{ config('app.name') }} collection

+
+
+ + +
+
+
+ + @foreach ($products as $key => $product) +
+
+ Image +
+
+ @endforeach + +
+
+
+ + +
+
+

New arrivals

+

Meet the Cartzilla collection

+
+
+ + + + + +
+
+ + @foreach ($products as $key => $product) +
+
+ +
+ +
+
+ +
{{ number_format($product->price, 0, ',', '.') }}
+
+
+ @endforeach + + +
+
+ + + +
+
+
+
diff --git a/resources/views/home/fashion-v1.blade.php b/resources/views/home/fashion-v1.blade.php index c6666c3..32262d4 100644 --- a/resources/views/home/fashion-v1.blade.php +++ b/resources/views/home/fashion-v1.blade.php @@ -1268,119 +1268,7 @@ -
-
-

New arrivals

-

Meet the Cartzilla collection

-
-
- - -
-
-
-
-
- Image -
-
-
-
- Image -
-
-
-
-
- - -
-
-

New arrivals

-

Meet the Cartzilla collection

-
-
- - - - - -
- -
- - - -
-
-
-
+