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
])
)
]);
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
])
)
]);