feat: safe-top and search

This commit is contained in:
2025-08-08 12:27:47 +03:00
parent 4ae8d59328
commit a8bb5eb493
13 changed files with 82 additions and 19 deletions

View File

@@ -50,6 +50,7 @@ class ProductsHandler
$page = $request->get('page', 1);
$perPage = 6;
$categoryId = (int) $request->get('categoryId', 0);
$search = trim($request->get('search', ''));
$categoryName = '';
@@ -100,7 +101,10 @@ class ProductsHandler
function (Builder $query) use ($featuredProducts) {
$query->whereIn('products.product_id', $featuredProducts);
}
);
)
->when($search, function (Builder $query) use ($search) {
$query->where('product_description.name', 'LIKE', '%' . $search . '%');
});
$total = $productsQuery->count();
$lastPage = PaginationHelper::calculateLastPage($total, $perPage);