search
This commit is contained in:
parent
5f81653f03
commit
11e8749bbb
6 changed files with 9 additions and 12 deletions
|
|
@ -142,6 +142,9 @@ class ProductsController extends Controller
|
|||
{
|
||||
/** @var Illuminate\Database\Eloquent\Builder */
|
||||
$productsQuery = Product::where('status', true);
|
||||
if (!empty($request->search)) {
|
||||
$productsQuery->where('name', 'LIKE', '%' . $request->search . '%');
|
||||
}
|
||||
if (!empty($request->promotion)) {
|
||||
$productsQuery->whereHas('promotions');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Range;
|
||||
use App\Models\Tag;
|
||||
use App\Models\Product;
|
||||
use Exception;
|
||||
use Illuminate\Bus\Queueable;
|
||||
|
|
@ -58,9 +57,6 @@ class RefreshSiteMap implements ShouldQueue
|
|||
'range' => [
|
||||
'rangeSlug' => [Range::class, 'slug']
|
||||
],
|
||||
'products.tagfilter' => [
|
||||
'tagSlug' => [Tag::class, 'slug']
|
||||
],
|
||||
'product' => [
|
||||
'productSlug' => [Product::class, 'slug']
|
||||
],
|
||||
|
|
|
|||
|
|
@ -196,9 +196,10 @@
|
|||
ranges: [],
|
||||
brands: [],
|
||||
tags: [],
|
||||
search: "",
|
||||
products: [],
|
||||
productsResults: 0,
|
||||
url: '',
|
||||
url: "",
|
||||
currentPage: 1,
|
||||
btnFilter: undefined,
|
||||
btnFilterCross: undefined
|
||||
|
|
@ -210,6 +211,7 @@
|
|||
this.ranges = jsonData.ranges ?? [];
|
||||
this.brands = jsonData.brands ?? [];
|
||||
this.tags = jsonData.tags ?? [];
|
||||
this.search = jsonData.search ?? "";
|
||||
this.products = jsonData.products ?? [];
|
||||
this.productsResults = jsonData.productsResults ?? 0;
|
||||
this.responsiveFilters();
|
||||
|
|
@ -284,6 +286,7 @@
|
|||
this.countFilter = 0;
|
||||
this.url = '/produits/filter?' ;
|
||||
this.url += `promotion=${filters.promotion ? '1' : '0'}`;
|
||||
this.url += (this.search) ? `&search=`+this.search : '';
|
||||
filters.promotion ? this.countFilter++ : '';
|
||||
filters.brands.map((value) => {
|
||||
this.url += `&brands[]=${value}`;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@
|
|||
'brands' => \App\Enums\ProductBrand::toArray(),
|
||||
'tags' => $tags,
|
||||
'products' => \App\Http\Resources\ProductResource::collection($products),
|
||||
'productsResults' => $products->perPage()
|
||||
'productsResults' => $products->perPage(),
|
||||
'search' => $filter
|
||||
];
|
||||
@endphp
|
||||
<filter-component json-data='@json($dataComponent)'/>
|
||||
|
|
|
|||
|
|
@ -95,10 +95,6 @@ Breadcrumbs::for('product', function ($trail, $product) {
|
|||
$trail->parent('products');
|
||||
$trail->push($product->name, route('product', ['productSlug' => $product->slug]));
|
||||
});
|
||||
Breadcrumbs::for('products.tagfilter', function ($trail, $tag) {
|
||||
$trail->parent('products');
|
||||
$trail->push($tag->label, route('products.tagfilter', ['tagSlug', $tag->slug]));
|
||||
});
|
||||
Breadcrumbs::for('search', function ($trail) {
|
||||
$trail->parent('products');
|
||||
$trail->push(__('Recherche'), route('search'));
|
||||
|
|
|
|||
|
|
@ -97,8 +97,6 @@ Route::get('/gamme-de-produits/{rangeSlug}', [ProductsController::class, 'range'
|
|||
Route::get('/produits', [ProductsController::class, 'allProducts'])->name('products');
|
||||
// Products filter ajax.
|
||||
Route::get('/produits/filter', [ProductsController::class, 'allProductsFiltered'])->name('products.filters');
|
||||
// Products tag filter.
|
||||
Route::get('/produits/{tagSlug}', [ProductsController::class, 'tagFiltered'])->name('products.tagfilter');
|
||||
// Product.
|
||||
Route::get('/produit/{productSlug}', [ProductsController::class, 'product'])->name('product')
|
||||
->middleware('redirect-slugs');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue