7

I've been using Laravel for a project and using the Eloquent models to grab the model instances I need.

However, it doesn't look like there's a way to query for not null values.

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

Is there a way to do something like this, where I want to get all Flight models where the ticket_id is not null?

$flight = App\Flight::where('ticket_id', '!=', null);

1 Answer 1

27

Try this

$flight = App\Flight::whereNotNull('ticket_id')->get();
Sign up to request clarification or add additional context in comments.

1 Comment

thks a lot, u saved me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.