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) + + + + + + @endforeach + + + + + + + + + New arrivals + Meet the Cartzilla collection + + + + + + + + + + + + + @foreach ($products as $key => $product) + + + + + + + + + + {{ $product->name }} + + + {{ 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 - - - - - - - - - - - - - - - - - - - - - - - - - New arrivals - Meet the Cartzilla collection - - - - - - - - - - - - - - - - - - - - - - - Sneakers with a massive sole - - - $86.50 - - - - - - - - - - - - - - Single breasted oversized blazer - - - $113.99 - - - - - - - - - - - - - +
New arrivals