Laravel Eloquent Nested Wheres (AND OR)

The code above is a Laravel Eloquent nested wheres query in a repository class. This query will return all users who are active and either free or on call. This is useful for getting a list of users who are available to do work.

The first where clause checks if the user is active. The second where clause uses a nested query to check if the user is free or on call. This is done by checking the status and on_call columns. If either of these columns is true, the user will be included in the results.

Leave a Reply

Your email address will not be published.