I have an eloquent query where I am not getting the expected results and I was hoping someone could explain to me what the correct way to write the query.

I have three tables:

```
records (belongsToMany users)
users (belongsToMany records)
record_user (pivot)

```

The `record_user` table also has a column for `role`.

I attempt to get all the records where the user has the `role` of either `singer` or `songwriter`:

```
$results = User::find(Auth::user()->id)
                    ->records()
                    ->wherePivot('role', 'singer')
                    ->orWherePivot('role', 'songwriter')
                    ->get();

```

Below is how the SQL syntax is generated:

```
select `records`.*, `record_user`.`user_id` as `pivot_user_id`,
`record_user`.`record_id` as `pivot_record_id` from `records` 
inner join `record_user` on `records`.`id` = `record_user`.`property_id` 
where
`record_user`.`user_id` = '1' and `record_user`.`role` = 'singer' or 
`record_user`.`role` = 'songwriter'

```

The results for `singer` role are what is expected: All records where the user is the singer. The problem is the results for the `songwriter`: I am getting ALL songwriters and the query is not constrained by the `user_id`. For some reason I was expecting the `songwriter` role to also be constrained by the `user_id` - what is the correct way to write this using the eloquent syntax?