TIP 28 / 36

A Shorter Way to Write Wherehas.

Released in Laravel 8.57: a shorter way to write whereHas() with a simple condition inside.

code
// Previous approach:
User::whereHas('posts', function ($query) {
    $query->where('published_at', '>', now());
})->get();

// Updated approach:
User::whereRelation('posts', 'published_at', '>', now())->get();