AND-OR-AND + brackets with Eloquent - Laravel Daily

PHOTO EMBED

Wed Apr 21 2021 23:26:30 GMT+0000 (UTC)

Saved by @mvieira

// ...
$q->where(function ($query) {
    $query->where('gender', 'Male')
        ->where('age', '>=', 18);
})->orWhere(function($query) {
    $query->where('gender', 'Female')
        ->where('age', '>=', 65);	
})
content_copyCOPY

https://laraveldaily.com/and-or-and-brackets-with-eloquent/