Laravel Eloquent Left Join Where Null Condition Example

By Hardik Savani | April 22, 2021 | Category : Laravel


This article goes in detailed on laravel eloquent left join where null condition. i explained simply about laravel left join with where condition. let’s discuss about laravel left join where null. you can see laravel left join get null records. Let's see bellow example laravel left join where clause.

Two days ago i was working on my old project and i need to get records that not match with left join table. i mean i have users table and i need to send notification users that does not post article yet. i see laravel documentation and find out solution to how to get not match records using where null condition. so i just want to share this example with you guys so someone helps.

Let's see simple example:

SQL Query:







ON posts.user_id =


posts.user_id IS NULL

Laravel Eloquent Query:

$data = User::leftJoin('posts', function($join) {

$join->on('posts.user_id', '=', '');





i hope it can help you...

Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.

We are Recommending you: