能把whereDoesntHave放在数组条件里,实现查询吗
Laravel 5.8.38
laravel-admin 1.7.6
PHP 版本:7.3.1
想用把查询条件放在数组里进行查询,如下
$where=[
['id','>',180],
['source','=','12']
['created_at','>=','2023-01-01']
];
$query->where($where);
其中有个查询要实现副表的某个字段值为空(副表字段为空, 也就是说,副表记录不存在,或对应字段为0),我是这样写的
$where[]= [function ($q) use($join,$column, $v ){
$q->whereDoesntHave($join)
->orWhere(function ($q)use($join,$column){
$q->whereHas($join,function ($q)use($column){
$q->whereNUll($column)->orWhere($column,0);
});
})
;
}];
但会报错
select count(*) as aggregate from `customer` where (`doesnt_have` = ext or (`has` = ext))) and customer.is_del= 0 group by `addcustomer`.`id`)
应该要怎么实现呢?
现在的处理是,如果是这种查询, 不放在数组里,