$username = '';// 收货人姓名
$hospital_id = ''; // 医院id
# 判断是否有姓名搜索
if (!empty($request->username)) {
$username = $request->username;
}
# 判断是否有医院搜索
if (!empty($request->hospital_id)) {
$hospital_id = $request->hospital_id;
}
# 执行
$data = DB::table('test')
->where(function($query)use($username){
# 进行判断
if (!empty($username)) {
$query->where('username','Like',"%$username%");
}
})
->where(function($query)use($hospital_id){
# 进行判断
if (!empty($hospital_id)) {
$query->where('hospital_id','=',$hospital_id);
}
})
->get()
->toArray();
dd($data)
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
长按识别二维码并关注微信
更方便到期提醒、手机管理