我在電子商務網站中應用搜索過濾器。在這裏,客戶可以選擇各種領域,如顏色,形狀,價格,對稱性,拋光,清晰度和各種其他的東西。 客戶選擇任何選項時,應添加到他選擇的最後一個選項。因此,他/她可能具有必須提取並顯示的條件組合。 對於一個數組條件,我可以使用whereIn在laravel中,但對於多個數組條件,我應該使用什麼。我不確定哪個數組將是空的。如何從多個陣列條件的laravel中的表中檢索數據
這裏是我的過濾器的代碼: -
public function Filter(Request $request)
{
$conditions = array();
if($request->isMethod('post')) {
$data = array_filter($request->all());
$shapes = array();
$amount = array();
$carat = array();
$cut = array();
$color = array();
$clarity = array();
$cerifying_agency = array();
$flourscence = array();
$polish = array();
$symmetry = array();
// $conditions=array();
if(isset($data['shape'])){
$shapes = $data['shape'];
}
if(isset($data['amount'])){
$amount = $data['amount'];
}
if(isset($data['carat'])){
$carat = $data['carat'];
}
if(isset($data['cut'])){
$cut = $data['cut'];
}
if(isset($data['color'])){
$color = $data['color'];
}
if(isset($data['clarity'])){
$clarity = $data['clarity'];
}
if(isset($data['ca'])){
$cerifying_agency = $data['ca'];
}
if(isset($data['fl'])){
$flourscence = $data['fl'];
}
if(isset($data['polish'])){
$polish = $data['polish'];
}
if(isset($data['symmetry'])){
$symmetry = $data['symmetry'];
}
}
}
我已附加UI的快照,並正被稱爲濾波器函數的陣列中對AJAX的數據格式: - Sorry I couldnt embed the picture as Stackoverflow is not allowing me to do so