How to check where not null query in Laravel Eloquent?

I was working on my laravel 5.6 application on this Sunday and I require to use a not null query with where condition in laravel eloquent. I mean I need to get all data that not null from the users table. So basically I know how to check not null in MySQL query but I didn't know how to retrieve data using laravel query builder. But I read laravel docs and got it we can do it using "whereNotNull()" of query builder function.

So here I am going to give you a very small example of whereNotNull() function. this task is very small and basic but if you use this one in your laravel app then it makes sense. So in whereNotNull() function we need to pass column name then laravel query builder will manage it how to get data from that column.

So let's see bellow example with syntax:




$users = User::select("*")




I hope you found your best solution....

March 27, 2018 | 1211 Viewer | Category : PHP Laravel
Related Posts