I have a table with:
Events
Cities
Clubs
The relations are as following:
- An
Event
'hasOne'Club
, and aClub
'hasMany'Event
s. - A
Club
'hasOne'City
and aCity
'hasMany'Club
s.
I want to add a filter to my query to get all events where the club.city == 'Oklahoma'
. This is what I tried:
$events = Event::where( 'accepted', 1 )
->with( [ 'club.city', 'organisation' ] )
->where( 'club.city.name', 'Rotterdam' )
->orderBy( 'created_at', 'asc' )
->paginate( 6 );