feat: safe-top and search
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user