Laravel WhereNotNull Query Example

Laravel 6 , Laravel , Laravel 7

Nicesnippets

1184

10-01-2020


Hi Guys,

In this example,I will learn you how to use whereNotNull query in laravel .you can simply use to whereNotNull query in your controller. we are so easy example where not null or not empty in laravel.

i will let you know how you can write query for where not null and where not null condition. here i will write core SQL query and then convert it into laravel query builder using db. So just see bellow example and see how it is works.

Example 1

/**

* Show the application dashboard.

*

* @return \Illuminate\Contracts\Support\Renderable

*/

public function index()

{

$news = \DB::table('availability')

->whereNotNull('availability_time')

->get();

dd($news);

}

Example 2

/**

* Show the application dashboard.

*

* @return \Illuminate\Contracts\Support\Renderable

*/

public function index()

{

$posts = \DB::table('property')

->whereNotNull('smoking')

->get();

dd($posts);

}

Example 3

/**

* Show the application dashboard.

*

* @return \Illuminate\Contracts\Support\Renderable

*/

public function index()

{

$users = User::whereNotNull('updated_at')->get();

dd($users);

}

It will help you...


Recommended Posts