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:
Syntax:
->whereNotNull('COLUMN_NAME');
Example:
$users = User::select("*")
->whereNotNull('google_id')
->get();
dd($users);
I hope you found your best solution....
Do you like below Tutorials ?
- Angular Json Pipe Example | Json Pipe in Angular 9/8/7
- Angular Slice Pipe Example | Slice Pipe in Angular 9/8/7
- Angular Uppercase Pipe Example | Uppercase Pipe in Angular 9/8/7
- Angular LowerCase Pipe Example | LowerCase Pipe in Angular 9/8/7
- Angular Titlecase Pipe Example | Titlecase Pipe in Angular 9/8/7
- Angular KeyValue Pipe Example | KeyValue Pipe in Angular 9/8/7
- Call Method from One Component to Another Component in Angular
- Angular Push Object into Array Example