Laravel雄辩的模型查询`not null`

use*_*289 4 php laravel eloquent

我一直在使用Laravel进行项目,并使用Eloquent模型来获取我需要的模型实例.

但是,它看起来不像查询not null值的方法.

https://laravel.com/docs/5.4/eloquent#retrieving-models

有没有办法做这样的事情,在这里我想获得的所有Flight车型,其中ticket_idnot null

$flight = App\Flight::where('ticket_id', '!=', null);
Run Code Online (Sandbox Code Playgroud)

A.k*_*ifa 20

试试这个

$flight = App\Flight::whereNotNull('ticket_id')->get();
Run Code Online (Sandbox Code Playgroud)