Hi there!
I am trying to use the filter method on a structure object. It is a structure field of dates (including a date
, a time
and an info
field).
$pastDates = $block->dates()->toStructure()->sortBy('date')->filter(function ($structureItem) {
return $structureItem->date()->toDate() < time();
});
I expect to receive a filtered list of structure items. But when I try to dump the result, I get something like this:
Kirby\Cms\Structure Object
(
[0] => 0
[1] => 1
)
I have no idea what went wrong, but I cannot access the dates anymore it seems? Can somebody please help me how I can use the filter method correctly?
Thanks!
trych