Skip to content

Commit

Permalink
add nextEvent field
Browse files Browse the repository at this point in the history
  • Loading branch information
mrothauer committed Feb 14, 2024
1 parent 6aca5e9 commit 0852470
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/Controller/WorkshopsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,12 @@ public function getWorkshopsWithCityFilter() {
'Categories.name' => 'asc',
]
],
'Events' => function($q) {
return $q->where([
'DATE_FORMAT(Events.datumstart, \'%Y-%m-%d\') >= DATE_FORMAT(NOW(), \'%Y-%m-%d\')',
])
->limit(1);
},
],
order: ['Workshops.name' => 'asc']);

Expand Down Expand Up @@ -452,7 +458,9 @@ public function getWorkshopsWithCityFilter() {
'landingPage' => Configure::read('AppConfig.serverName') . Configure::read('AppConfig.htmlHelper')->urlWorkshopDetail($workshop->url),
'logoUrl' => $workshop->image != '' ? Configure::read('AppConfig.serverName') . Configure::read('AppConfig.htmlHelper')->getThumbs150Image($workshop->image, 'workshops') : Configure::read('AppConfig.serverName') . Configure::read('AppConfig.htmlHelper')->getThumbs100Image('rclogo-100.jpg', 'workshops'),
'category' => $preparedCategories,
'nextEvent' => !empty($workshop->events[0]) ? $workshop->events[0]->datumstart_formatted : null,
];

}

$this->set([
Expand Down
3 changes: 2 additions & 1 deletion tests/comparisons/rest-workshops-berlin.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"label": "3D-Reparatur",
"iconUrl": "{{serverName}}\/img\/icon-skills\/drei-d-reparatur.png"
}
]
],
"nextEvent": "2040-01-01"
}
]
}

0 comments on commit 0852470

Please sign in to comment.