Exclude future talks from the count
This commit is contained in:
parent
52565c99f1
commit
6c10410a20
4 changed files with 299 additions and 8 deletions
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\TwigExtension;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFunction;
|
||||
|
@ -26,7 +27,11 @@ final class TalkExtension extends AbstractExtension
|
|||
{
|
||||
$talkCollection = new Collection($talks);
|
||||
|
||||
$today = Carbon::today()->format('Y-m-d');
|
||||
|
||||
return $talkCollection
|
||||
->flatMap(fn($talk): array => (array) $talk['events']);
|
||||
->flatMap(fn($talk): array => (array) $talk['events'])
|
||||
->filter(fn(array $event): bool => $event['date'] < $today);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue