From e0e853e2b803c4a66294a8c1f075d330b390f96a Mon Sep 17 00:00:00 2001 From: Bayu Lukman Yusuf Date: Tue, 6 Jan 2026 14:12:36 +0700 Subject: [PATCH] list product, show list filter category, gender --- app/Http/Controllers/ProductController.php | 43 +- app/Models/StoreCategory.php | 2 + lang/en/catalog_fashion.php | 14 + lang/id/catalog_fashion.php | 14 + .../layout/navbar-category.blade.php | 2 +- .../views/shop/catalog-fashion.blade.php | 767 ++---------------- routes/web.php | 1 + 7 files changed, 150 insertions(+), 693 deletions(-) create mode 100644 lang/en/catalog_fashion.php create mode 100644 lang/id/catalog_fashion.php diff --git a/app/Http/Controllers/ProductController.php b/app/Http/Controllers/ProductController.php index 152e74e..2e57ec7 100644 --- a/app/Http/Controllers/ProductController.php +++ b/app/Http/Controllers/ProductController.php @@ -2,18 +2,50 @@ namespace App\Http\Controllers; -use App\Models\Items; +use App\Repositories\Catalog\CategoryRepository; +use App\Repositories\Catalog\GenderRepository; use App\Repositories\Catalog\ProductRepository; use Illuminate\Http\Request; class ProductController extends Controller { + public function index(Request $request) + { + + $page = $request->page ?? 1; + + $filters = $request->filter ?? []; + $sortBy = $request->sort_by ?? 'relevance'; + + $genderRepository = new GenderRepository; + $categoryRepository = new CategoryRepository; + + $genders = $genderRepository->getList([]); + $categories = $categoryRepository->getList([]); + + $productRepository = new ProductRepository; + $products = $productRepository->getList([ + 'limit' => 20, + 'sort_by' => $sortBy, + ]); + + + + return view('shop.catalog-fashion', [ + 'filters' => $filters, + 'genders' => $genders, + 'categories' => $categories, + + 'products' => $products, + 'page' => $page, + ]); + } + public function detail($slug, Request $request, ProductRepository $productRepository) { $product = $productRepository->show($slug); - $complete_look_products_data = $productRepository->getList([ 'category_id' => $product->category1_id, 'limit' => 4, @@ -21,11 +53,10 @@ class ProductController extends Controller $complete_look_products = collect($complete_look_products_data->items())->chunk(2); - - return view('shop.product-fashion',[ - 'product' => $product, + return view('shop.product-fashion', [ + 'product' => $product, 'complete_look_products' => $complete_look_products, - + ]); } } diff --git a/app/Models/StoreCategory.php b/app/Models/StoreCategory.php index 74954e8..4fdf316 100644 --- a/app/Models/StoreCategory.php +++ b/app/Models/StoreCategory.php @@ -22,4 +22,6 @@ class StoreCategory extends Model { return $this->hasMany(StoreCapacity::class); } + + } diff --git a/lang/en/catalog_fashion.php b/lang/en/catalog_fashion.php new file mode 100644 index 0000000..839f0a9 --- /dev/null +++ b/lang/en/catalog_fashion.php @@ -0,0 +1,14 @@ + 'Categories', + 'genders' => 'Genders', + 'price' => 'Price', + 'filter' => 'Filter', + 'sort_by' => 'Sort by', + 'sort_relevance' => 'Relevance', + 'sort_popularity' => 'Popularity', + 'sort_price_low_to_high' => 'Price: Low to High', + 'sort_price_high_to_low' => 'Price: High to Low', + 'sort_newest_arrivals' => 'Newest Arrivals', +]; \ No newline at end of file diff --git a/lang/id/catalog_fashion.php b/lang/id/catalog_fashion.php new file mode 100644 index 0000000..549e36a --- /dev/null +++ b/lang/id/catalog_fashion.php @@ -0,0 +1,14 @@ + 'Kategori', + 'genders' => 'Gender', + 'price' => 'Harga', + 'filter' => 'Filter', + 'sort_by' => 'Urutkan', + 'sort_relevance' => 'Relevan', + 'sort_popularity' => 'Popularitas', + 'sort_price_low_to_high' => 'Harga: Dari Rendah ke Tinggi', + 'sort_price_high_to_low' => 'Harga: Dari Tinggi ke Rendah', + 'sort_newest_arrivals' => 'Terbaru', +]; \ No newline at end of file diff --git a/resources/views/components/layout/navbar-category.blade.php b/resources/views/components/layout/navbar-category.blade.php index 82e904f..fb686cc 100644 --- a/resources/views/components/layout/navbar-category.blade.php +++ b/resources/views/components/layout/navbar-category.blade.php @@ -57,7 +57,7 @@ @foreach ($chunks as $chunk)
  • {{ $chunk->name }} + href="{{ route('product.index', ['filter[category]' => $chunk->name, 'filter[gender]' => $gender->name]) }}">{{ $chunk->name }}
  • @endforeach diff --git a/resources/views/shop/catalog-fashion.blade.php b/resources/views/shop/catalog-fashion.blade.php index 5db95cc..c30e134 100644 --- a/resources/views/shop/catalog-fashion.blade.php +++ b/resources/views/shop/catalog-fashion.blade.php @@ -218,50 +218,65 @@ -
    - -
    -
    -

    Filter

    - +
    + @if (count($filters) > 0) + +
    +
    +

    Filter

    + + Clear all + +
    +
    + @foreach ($filters as $key => $filter) + + @endforeach + +
    -
    - - - - - -
    -
    + @endif
    + +
    +

    + +

    +
    +
    +
    + +
    +
    +
    +
    -
    + {{--

    -
    +
    --}} -
    + {{--

    -
    +
    --}} -
    + {{--

    - + --}}
    @@ -742,11 +659,11 @@
    -
    Found 32 +
    Found {{ count($products) }} items
    - +
    @@ -767,327 +685,17 @@
    - -
    -
    -
    - Sale - - -
    - Image -
    -
    -
    -
    - XS - S - M - L - -
    -
    -
    - -
    $126.50 $156.00 -
    -
    -
    +1 color
    -
    - - - - -
    -
    + @foreach ($products as $key => $value) + +
    +
    -
    + @endforeach - -
    -
    -
    - - -
    - Image -
    -
    -
    -
    - S - M - L - XL - -
    -
    -
    - -
    $54.00
    -
    -
    +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 -
    -
    -
    -
    - M - L - XL -
    -
    -
    - -
    $27.00
    -
    -
    +3 colors
    -
    - - - - - - - - -
    -
    -
    -
    -
    + {{--

    Sweatshirts

    @@ -1125,228 +733,16 @@ href="{{ route('second', ['shop', 'product-fashion']) }}">Shop now
    -
    +
    --}} - -
    -
    -
    - - -
    - Image -
    -
    -
    -
    - 6 - 6.5 - 7 - 7.5 - -
    -
    -
    - -
    $160.00
    -
    -
    +1 color
    -
    - - - - -
    -
    -
    -
    - - -
    -
    -
    - - -
    - Image -
    -
    -
    -
    - 6.5 - 7 - 7.5 - 8 - -
    -
    -
    - -
    $74.00
    -
    -
    +2 colors
    -
    - - - - - - -
    -
    -
    -
    - - -
    -
    -
    - - -
    - Image -
    -
    -
    -
    - XS - S - M - L - -
    -
    -
    - -
    $38.50
    -
    -
    +1 color
    -
    - - - - -
    -
    -
    -
    - - -
    -
    -
    - - -
    - Image -
    -
    -
    - -
    $140.00
    -
    -
    +2 colors
    -
    - - - - - - -
    -
    -
    -
    +
    - +
    @@ -1423,8 +819,7 @@ diff --git a/routes/web.php b/routes/web.php index ad105d3..fffb901 100644 --- a/routes/web.php +++ b/routes/web.php @@ -23,4 +23,5 @@ Route::post('/locale/switch', [LocaleController::class, 'switch'])->name('locale Route::get('/', [HomeController::class, 'index'])->name('home'); +Route::get('/products',[ProductController::class, 'index'])->name('product.index'); Route::get('/product/{slug}',[ProductController::class, 'detail'])->name('product.detail'); \ No newline at end of file