如何检查字段是否为雄辩不为空?
我试着模型::(‘sent_at’,‘不是’,DB::生(“空”))- >…但它给出了IS NOT作为一个绑定,而不是一个比较。
这是DB::getQueryLog()所说的:
'query' => string 'select * from my_table where sent_at = ? and profile_id in (?, ?) order by created_at desc' (length=101)
'bindings' =>
array (size=3)
0 => string 'IS NOT' (length=6)
1 => int 1
2 => int 4
如果像我这样的人想用Laravel 5.2.23中的查询生成器来做,可以像->这样做
$searchResultQuery = Users::query();
$searchResultQuery->where('status_message', '<>', '', 'and'); // is not null
$searchResultQuery->where('is_deleted', 'IS NULL', null, 'and'); // is null
或与scope in model:
public function scopeNotNullOnly($query){
return $query->where('status_message', '<>', '');
}
如果像我这样的人想用Laravel 5.2.23中的查询生成器来做,可以像->这样做
$searchResultQuery = Users::query();
$searchResultQuery->where('status_message', '<>', '', 'and'); // is not null
$searchResultQuery->where('is_deleted', 'IS NULL', null, 'and'); // is null
或与scope in model:
public function scopeNotNullOnly($query){
return $query->where('status_message', '<>', '');
}