使用orderRaw()
我的有null值的 字段是 position
1.null 值在最后:
$data = $this->article->orderRaw('if(isnull(position),1,0),position,update_time desc')->select();
2.null 值在最前:
$data = $this->article->orderRaw('if(isnull(position),0,1),position,update_time desc')->select();