From ddcea440af716ab025d9c6b8d78fafa32bac6ce8 Mon Sep 17 00:00:00 2001 From: Bayu Lukman Yusuf Date: Mon, 5 Jan 2026 16:18:06 +0700 Subject: [PATCH] component viewed products, navbar description, delivery retur --- app/Http/Controllers/ProductController.php | 13 +- .../Catalog/ProductRepository.php | 64 +- app/View/Components/Layout/NavbarMenu.php | 25 + app/View/Components/Shop/ViewedProducts.php | 34 + lang/en/product_fashion.php | 8 + lang/id/product_fashion.php | 8 + .../components/layout/navbar-menu.blade.php | 222 +++++ .../components/shop/viewed-products.blade.php | 52 ++ resources/views/home/fashion-v1.blade.php | 284 +------ .../views/shop/product-fashion.blade.php | 793 ++---------------- 10 files changed, 454 insertions(+), 1049 deletions(-) create mode 100644 app/View/Components/Layout/NavbarMenu.php create mode 100644 app/View/Components/Shop/ViewedProducts.php create mode 100644 lang/en/product_fashion.php create mode 100644 lang/id/product_fashion.php create mode 100644 resources/views/components/layout/navbar-menu.blade.php create mode 100644 resources/views/components/shop/viewed-products.blade.php diff --git a/app/Http/Controllers/ProductController.php b/app/Http/Controllers/ProductController.php index a2e3e57..152e74e 100644 --- a/app/Http/Controllers/ProductController.php +++ b/app/Http/Controllers/ProductController.php @@ -11,13 +11,7 @@ class ProductController extends Controller public function detail($slug, Request $request, ProductRepository $productRepository) { - $product = Items::where('slug', $slug)->first(); - - - if ($product == null) { - abort(404); - } - + $product = $productRepository->show($slug); $complete_look_products_data = $productRepository->getList([ @@ -25,14 +19,13 @@ class ProductController extends Controller 'limit' => 4, ]); - - $complete_look_products = collect($complete_look_products_data->items())->chunk(2); return view('shop.product-fashion',[ 'product' => $product, - 'complete_look_products' => $complete_look_products + 'complete_look_products' => $complete_look_products, + ]); } } diff --git a/app/Repositories/Catalog/ProductRepository.php b/app/Repositories/Catalog/ProductRepository.php index 89df759..9c9061c 100644 --- a/app/Repositories/Catalog/ProductRepository.php +++ b/app/Repositories/Catalog/ProductRepository.php @@ -30,29 +30,29 @@ class ProductRepository ( discounts.valid_at is null or discounts.expired_at >= now()) order by item_id, discounts.created_at desc ) as d"),"d.item_id","=","items.id") -->when(true, function($query) use ($event, $sort){ -if ($event){ - $query->orderByRaw("case when brand = 'CHAMELO' then 1 else 2 end ASC "); + ->when(true, function($query) use ($event, $sort){ + if ($event){ + $query->orderByRaw("case when brand = 'CHAMELO' then 1 else 2 end ASC "); -$query->orderBy("percent", "desc"); -}else{ + $query->orderBy("percent", "desc"); + }else{ -/* if ($event == "special-offer"){ -$query->orderByRaw("case when brand = 'CHAMELO' then 1 else 2 end ASC "); -} */ + /* if ($event == "special-offer"){ + $query->orderByRaw("case when brand = 'CHAMELO' then 1 else 2 end ASC "); + } */ -if ($sort == "new"){ -\Log::info($sort); + if ($sort == "new"){ + \Log::info($sort); - $query->orderByRaw("case when category1 in ('CLUBS','CLUB','COMPONENT HEAD') and brand = 'PXG' then 1 else 2 end ASC"); -}else{ - $query->orderByRaw("case when d.created_at is not null then 1 else 2 end ASC, random()"); -} + $query->orderByRaw("case when category1 in ('CLUBS','CLUB','COMPONENT HEAD') and brand = 'PXG' then 1 else 2 end ASC"); + }else{ + $query->orderByRaw("case when d.created_at is not null then 1 else 2 end ASC, random()"); + } -// $query->orderByRaw("items.created_at desc NULLS LAST"); -} + // $query->orderByRaw("items.created_at desc NULLS LAST"); + } -}) + }) ->where("is_publish", true) ->when($search, function ($query) use ($search) { $query->where(function ($query) use ($search) { @@ -94,4 +94,34 @@ if ($sort == "new"){ return $builder->paginate($limit); } + + public function show($slug) + { + $product = Items::where('slug', $slug)->first(); + + + + if ($product == null) { + abort(404); + } + + $all = session()->get('viewed_products', []); + $all[] = $product->id; + session()->put('viewed_products', array_unique($all)); + + return $product; + } + + public function viewed_products($except_ids = []) + { + $ids = session()->get('viewed_products', []); + if (empty($ids)) { + return collect(); + } + + // Remove except_ids from the list + $ids = array_diff($ids, (array)$except_ids); + + return Items::whereIn('id', $ids)->inRandomOrder()->take(10)->get(); + } } diff --git a/app/View/Components/Layout/NavbarMenu.php b/app/View/Components/Layout/NavbarMenu.php new file mode 100644 index 0000000..fb5a003 --- /dev/null +++ b/app/View/Components/Layout/NavbarMenu.php @@ -0,0 +1,25 @@ +viewedProducts = $productRepository->viewed_products($except_ids); + + } + + /** + * Get the view/contents that represent the component. + */ + public function render(): View + { + return view('components.shop.viewed-products'); + } +} diff --git a/lang/en/product_fashion.php b/lang/en/product_fashion.php new file mode 100644 index 0000000..5c5c696 --- /dev/null +++ b/lang/en/product_fashion.php @@ -0,0 +1,8 @@ + 'Description', + 'delivery' => 'Delivery', + 'and_returns' => 'and Returns', + 'review' => 'Review' +]; \ No newline at end of file diff --git a/lang/id/product_fashion.php b/lang/id/product_fashion.php new file mode 100644 index 0000000..076ce8b --- /dev/null +++ b/lang/id/product_fashion.php @@ -0,0 +1,8 @@ + 'Deskripsi', + 'delivery' => 'Pengiriman', + 'and_returns' => 'dan Retur', + 'review' => 'Ulasan' +]; \ No newline at end of file diff --git a/resources/views/components/layout/navbar-menu.blade.php b/resources/views/components/layout/navbar-menu.blade.php new file mode 100644 index 0000000..ecb2a12 --- /dev/null +++ b/resources/views/components/layout/navbar-menu.blade.php @@ -0,0 +1,222 @@ + + diff --git a/resources/views/components/shop/viewed-products.blade.php b/resources/views/components/shop/viewed-products.blade.php new file mode 100644 index 0000000..8be88dd --- /dev/null +++ b/resources/views/components/shop/viewed-products.blade.php @@ -0,0 +1,52 @@ +@if (count($viewedProducts) > 0) +
+
+

Viewed products

+ + +
+ + +
+
+ + +
+
+ + @foreach ($viewedProducts as $key => $product) + +
+ +
+ @endforeach + + +
+
+
+@endif \ No newline at end of file diff --git a/resources/views/home/fashion-v1.blade.php b/resources/views/home/fashion-v1.blade.php index 50c3950..1ee6938 100644 --- a/resources/views/home/fashion-v1.blade.php +++ b/resources/views/home/fashion-v1.blade.php @@ -689,289 +689,7 @@ - + - + --}} @@ -1993,9 +1561,22 @@ aria-labelledby="description-tab">
- {!! nl2br($product->description) !!} + Pastikan apakah stock tersedia dengan terlebih dahulu KIRIM PESAN - TANYA kepada kami, +
+
+ Segera lakukan pembayaran saat melakukan checkout produk agar system order bisa langusung terima dan proses kemas, +
+
+- Layanan Pengiriman "Instant" tersedia (Prioritas) kami upayakan proses langsung, +
+- Layanan Pengiriman "Sameday" Maksimal order masuk pukul 15.00 Wib karna maksimal Request pick up yang di tentukan oleh tokopedia pukul 16.00 Wib,. +
+- Layanan pengiriman "Regullar - Yes - Cargo" Kami pastikan produk terkirim status berubah terkirim pada Sore menjelang petan karna kami hanya tersedia 1x pengiriman ke jasa pengiriman dalam 1 hari +
+
+Pesanan masuk pukul 18.00 Wib ke atas kemungkinan akan kami proses kirim dan ikut pengiriman ke jasa pengiriman ke esokan harinya,.
-
+ {{--
@@ -2029,7 +1610,7 @@
-
+
--}}
@@ -2081,33 +1662,41 @@
-
Delivery
-

We strive to deliver your denim midi skirt with pockets to you as quickly as possible. - Our estimated delivery times are as follows:

-
    -
  • Standard delivery: Within 3-7 - business days
  • -
  • Express delivery: Within 1-3 business - days
  • -
-

Please note that delivery times may vary depending on your location and any ongoing - promotions or holidays. You can track your order using the provided tracking number once - your package has been dispatched.

+
Pengiriman
+

Kami bekerja sama dengan berbagai penyedia jasa pengiriman terpercaya untuk memastikan proses pengiriman pesanan berjalan dengan aman dan efisien. +
+
+ Pelanggan diberikan kebebasan untuk memilih layanan pengiriman yang paling sesuai dengan kebutuhan, baik dari segi kecepatan maupun biaya. +
+
+ Estimasi waktu pengiriman dapat berbeda-beda tergantung pada jenis layanan yang dipilih, lokasi tujuan, serta kebijakan dan kondisi operasional dari masing-masing penyedia jasa pengiriman. +
+
+ Perlu diperhatikan bahwa keterlambatan yang disebabkan oleh faktor di luar kendali kami merupakan tanggung jawab penyedia jasa terkait. +
+
+ Meskipun demikian, kami akan senantiasa membantu memantau status pengiriman guna memastikan pesanan sampai ke tangan pelanggan dengan baik.

-
Returns
-

We want you to be completely satisfied with your denim midi skirt with pockets. If for - any reason you are not happy with your purchase, you can return it within 30 days of - receiving your order for a full refund or exchange.

-

To be eligible for a return, the skirt must be unused, unwashed, and in its original - condition with tags attached. Please ensure that all packaging is intact when returning - the item.

-

To initiate a return, please contact our customer service team with your - order number and reason for the return. We will provide you with a return shipping label - and instructions on how to proceed. Please note that shipping fees are non-refundable. -

+
Return Barang
+

Kami memberikan kesempatan kepada pelanggan untuk mengajukan permohonan retur atas produk yang diterima apabila terdapat ketidaksesuaian atau kendala tertentu. Proses pengajuan retur dapat dilakukan dengan menghubungi customer service resmi kami melalui WhatsApp. +
+
+ Untuk keperluan verifikasi, pelanggan diwajibkan mengirimkan informasi detail transaksi pembelian, foto produk yang diterima, serta bukti video unboxing yang jelas dan tidak terputus. +
+
+ Permohonan retur akan ditinjau sesuai dengan ketentuan dan kebijakan yang berlaku. +
+
+ Setelah proses verifikasi selesai dan disetujui, kami akan memberikan informasi lebih lanjut terkait tahapan pengembalian barang maupun solusi yang dapat diberikan kepada pelanggan. +
+
+ Kami berkomitmen untuk menyelesaikan setiap permohonan retur dengan cepat dan profesional sesuai dengan standar pelayanan kami. +
+
+ Untuk informasi lebih lanjut, pelanggan dapat menghubungi customer service kami melalui WhatsApp.

@@ -2426,281 +2015,7 @@ - -
-
-

Viewed products

- - -
- - -
-
- - -
-
- - -
-
-
- - -
- Image -
-
-
-
- S - M - L - XL - -
-
-
- -
$32.99
-
-
+2 colors
-
- - - - - - -
-
-
-
- - -
-
-
- - -
- Image -
-
-
-
- 6 - 6.5 - 7 - 7.5 - -
-
-
- -
$86.50
-
-
+1 color
-
- - - - -
-
-
-
- - -
-
-
- - -
- Image -
-
-
- -
$105.00
-
-
+1 color
-
- - - - -
-
-
-
- - -
-
-
- -17% - - -
- Image -
-
-
- -
$96.00 $112.00 -
-
-
+2 colors
-
- - - - - - -
-
-
-
- - -
-
-
- - -
- Image -
-
-
- -
$140.00
-
-
+2 colors
-
- - - - - - -
-
-
-
-
-
-
+