I am new to Craft CMS. I am able to get a list off all upcoming events with:
$events = Calendar::getInstance()->events ->getEventQuery( [ 'calendar' => 'sample_calendar', 'rangeStart' => 'now', 'limit' => 10, 'enabledForSite' => true, 'orderBy' => 'startDate asc' ] );
An individual query can get me the city location with:
$city = $events->one()->eventLocation->one()->addressLocation->parts->city;
However, this does me no good because I am looking to get ALL events that are in Chicago.
I have tried:
$chicagoEvents = $events->where(['eventLocation.addressLocation.parts.city' => 'Chicago']);
This results in:
Database Exception – yii\db\Exception SQLSTATE[42S22]: Column not found: 1054 Unknown column 'eventLocation' in 'where clause'
Any idea how I can do an event query and filter by the event location?
Note: an event can have multiple locations (and in the CMS, eventLocation is a matrix field).