1$user->posts()2 ->where('active', 1)3 ->orWhere('votes', '>=', 100)4 ->get();
Returns: ALL posts where votes are greater than or equal to 100 are returned
1select * from posts where user_id = ? and active = 1 or votes >= 100
1use Illuminate\Database\Eloquent\Builder;2 3$users->posts()4 ->where(function (Builder $query) {5 return $query->where('active', 1)6 ->orWhere('votes', '>=', 100);7 })8 ->get();
Returns: Users posts where votes are greater than or equal to 100 are returned
1select * from posts where user_id = ? and (active = 1 or votes >= 100)
Tip given by @BonnickJosh