Not Bad:
This returns ALL posts where votes are greater than or equal to 100 are returned.
$user->posts()->where('active', 1)->orWhere('votes', '>=', 100)->get();
Good:
This returns Users posts where votes are greater than or equal to 100 are returned.
use Illuminate\Database\Eloquent\Builder;
$users->posts()->where(function (Builder $query) {
return $query->where('active', 1)->orWhere('votes', '>=', 100);
})->get();
Top comments (0)