2
我需要使用laravel进行搜索5.4。我有下一个搜索字段Laravel - 在where子句中的多个值
我想搜索这7个字段。我用这个查询:
if ($categoryIn <> '' AND
$brandIn == ' ' AND
$model == ' ' AND
$fuelIn == '' AND
$priceMinIn == '0' AND
$priceMaxIn == '0' AND
$kmm == '0') {
$cars = Cars_models::Where('Categorie', 'LIKE', $categoryIn)->get();
}
else if ($categoryIn <> '' AND
$brandIn <> ' ' AND
$model == ' ' AND
$fuelIn == '' AND
$priceMinIn == '0' AND
$priceMaxIn == '0' AND
$kmm == '0') {
$cars = Cars_models::Where('Categorie','LIKE',$categoryIn)
->Where('Brand', 'LIKE', $brandIn)
->get();
} else if...
但我有很多组合。任何人都可以帮我展示一个更简单的方法吗?因为我不能处理它,如果我写这样的每一个组合。
有什么想法?
看到这里,这将帮助你https://stackoverflow.com/questions/45511015/writing-a-function-in-laravel –
伟大的你有解决方案 –