Good morning, I have this query that is like a search engine, only for products where the brand is "strong" .. in the parameter $ word, it can only bring a description of the product or code.
When I send a description of the product, the search engine works for me, but when I send a code it gives me the codes of other brands as a result, but I only need the strong brand.
public static function busqueda($palabra){
$producto = self::join('ped_unidades_medida','vcomp_productos_web1.unidad','=','ped_unidades_medida.unidad_uid')
->where('vcomp_productos_web1.marca','forte')
->where('vcomp_productos_web1.descripcion','like','%'.$palabra.'%')
->orwhere('vcomp_productos_web1.codigo','like','%'.$palabra.'%')
->select(['vcomp_productos_web1.*','ped_unidades_medida.unidad_descripcion'])
->where('vcomp_productos_web1.venta_web','SI')
->paginate(9);
return $producto;
}
A result when I search by description
When I enter a code for a product that is not strong, it brings me this result, which is wrong ... I should only look for products where the brand is strong.
I leave here the SQL query. Suppose that $ word is 18
SELECT * FROM vcomp_productos_web1
JOIN ped_unidades_medida ON vcomp_productos_web1.unidad = ped_unidades_medida.unidad_uid
WHERE vcomp_productos_web1.marca = 'FORTE'
AND vcomp_productos_web1.venta_web = 'SI'
AND vcomp_productos_web1.descripcion LIKE '%$palabra%'
OR vcomp_productos_web1.codigo LIKE '%$palabra%'