我正在使用以下口才:
Book::selectRaw("name")
->where($bookWheres)
->with(['chapter'=>function ($query) use($chapterWheres)
{
$query->where($chapterWheres);
}])
->get()->dd();
要设置$bookWheres / $chapterWheres
,请使用数组['xx', '>=', '5']
。但是,对于$chapterWhere
,我还需要类似于['timestamp','is','null']的推送,因为它将检查timestamp列是否为空/空。
->whereNull('timestamp')
通常可以正常工作。但是where子句['timestamp', 'is', 'null']
是一个过滤器,因此它也可能是not null, >= or <=.
是否可以将“ is null”推入数组?
Laravel 7。
答案 0 :(得分:0)
Check it out> 试试这个对你来说会有用的
Book::selectRaw("name")
->where([$bookWheres])
->with(['chapter'=>function ($query) use($chapterWheres)
{
$query->where([$chapterWheres]);
}])
->get();