laravel 连续where查询
laravel 连续查询:
$data = $request->all('page_type','page_port','page_domian','is_promote');
$pagelist = PageList::where(function ($query) use ($data) {
foreach ($data as $k => $v) {
if ($k == 'page_type') {
if (!empty($v)) {
$query->where('page_type','=',$v);
}
}elseif ($k == 'page_port'){
if (!empty($v)) {
$query->where('page_port','like','%'.$v.'%');
}
}elseif ($k == 'page_domian'){
if (!empty($v)) {
$query->where('page_domian','like','%'.$v.'%');
}
}elseif ($k == 'is_promote'){
if (!empty($v)) {
$query->where('is_promote', $v);
}
}
}
})->get()->toArray();
还没有评论,快来发表第一个评论吧