'SQL search query where the product name
Here the sample product name "SRM - DAZA RS3 TTRS GTX35 Turbo"
sql like query i'm using this
->where(function ($q) use ($query) {
foreach (explode(' ', trim($query)) as $word) {
$q->where('name', 'like', '%' . $word . '%')
->orWhere('description', 'like', '%' . $word . '%')
->orWhere('tags', 'like', '%' . $word . '%')
->orWhereHas('product_translations', function ($q) use ($word) {
$q->where('name', 'like', '%' . $word . '%')
->orWhere('description', 'like', '%' . $word . '%');
})
->orWhereHas('stocks', function ($q) use ($word) {
$q->where('sku', 'like', '%' . $word . '%');
});
}
})
this works perfect but still have an issue. if i search "SRM" im getting this specific product
but if i type mix match word "SRM turbo" im not getting this product.
so please let me know what is the right query that i need to use
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
