laravel多条件搜索

$infoList = Order::select('order.order_Sn','order.amount','order.address','order.money','order.send_time','order.status','order.type','order.pos_id');


//根据货币类型查询
if ($unit){
    $infoList->where('unit',$unit);
}
//根据pos_id查询
if ($pos_id){
    $infoList->where('pos_id',$pos_id);
}
//根据订单时间查询
if ($start_time){
    $infoList->where('send_time','>',$start_time);
}
if ($end_time){
    $infoList->where('send_time','<',$end_time);
}
//根据订单号查询
if ($order_sn){
    $infoList->where('order_sn',$order_sn);
}
//根据pos_id查询
if ($pos_id){
    $infoList->where('pos_id',$pos_id);
}
//查询数据总条数
$total = $infoList->count();
//计算总页码
$last_page = ceil($total/$pageSize);
$infoList = $infoList->get();

猜你喜欢

转载自blog.csdn.net/m0_37971044/article/details/83023172