Ensure that talks are sorted by the nearest event date

This commit is contained in:
Oliver Davies 2019-01-18 20:38:58 +00:00
parent 18e6d2e32f
commit 303162e65d
2 changed files with 29 additions and 2 deletions

View file

@ -46,7 +46,9 @@ class TalksExtension extends Twig_Extension
*/
public function getAll($talks, array $eventData = []): Collection
{
return collect($talks);
return collect($talks)->sortBy(function ($talk) {
return collect($talk['events'])->pluck('date')->sort()->last();
});
}
/**