RepeatableEntry state modification aren't possible?

Hi.

I am building something kind of complex: I need to modify the state of a RepeatableEntry to.

The example is built for a visit tracking system.
Each session (the record I'm working on) has multiple page views.

I would like to display the duration of the page view duration based on the previous entry of the repeatable.
return $infolist
    ->schema([
        // List all page views of the visitor session
        RepeatableEntry::make('pageViews')
            ->schema([
                // The page view path
                TextEntry::make('Path')
                    ->columnSpanFull(),

                // The duration of the visit for this page
                TextEntry::make('Duration')
            ])

            // Is this somehow possible?
            ->state(
                fn(Session $record) => $record->pageViews
                    ->map(fn(PageView $pageView, int $key) => [
                        'path' => $pageView->path,
                        'duration' => isset($record->pageViews[$key+1]) ? $pageView->created_at->diff($record->pageViews[$key+1]->created_at) : null
                    ])
            )
    ]);


It kind of works in the sense that my state callback is evaluated and the page displays the correct number of entries but the data isn't filled inside each entry
Was this page helpful?