这种写法不正确,‘notice_cad’ function里面有带条件whereIn,外面要加一层whereHas
$data = ProofingNotice::with(['notice_cad' => function ($qn) {
$qn->with(['user_name'])->whereIn('flag', [4]);
}, 'exploit' => function ($qs) {
$qs->with(['client', 'brand', 'devedep', 'deveaids', 'client_branch']);
}, 'notice_cad_review', 'colors'])
->whereIn('status', $arr_status)
->whereIn('area_id', $place_from)
->whereBetween('review_date', [$start_date, $end_date])
->get()->toArray();
上面的写法应改为:
$data = ProofingNotice::with(['notice_cad'=>function($w){
$w->with(['user_name'])->whereIn('flag', [4]);
}, 'exploit', 'colors','notice_cad_review'])
->whereHas('notice_cad', function ($qn) {
$qn->with(['user_name'])->whereIn('flag', [4]);
})
->whereHas('exploit', function ($qs) {
$qs->with(['client', 'brand', 'devedep', 'deveaids', 'client_branch']);
})
->whereIn('status', $arr_status)
->whereIn('area_id', $place_from)
->where(function ($qd) use ($start_date, $end_date) {
$qd->whereBetween('nuclear_date', [$start_date, $end_date]);
$qd->orwhereBetween('transport_date', [$start_date, $end_date]);
})->get()->toArray();
别问为什么,不知道
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。