I'm trying to list courses in sections (instead of a table). But for every course it returns the same data (data of the last course) in the infolist. The header and the description of the course are displayed correctly.
public function content(Schema $schema): Schema
{
return $schema
->columns([
'default' => 3,
])
->components($this->getTableRecords()->sortBy('start_at')->map(function ($course) use ($schema) {
$infolist = CourseResource::infolist($schema)->record($course)->getFlatComponents(withAbsoluteKeys: true);
unset($infolist['name']);
unset($infolist['description']);
unset($infolist['start_enrollment_at']);
unset($infolist['end_enrollment_at']);
return Section::make($course->name)
->model($course)
->description($course->description)
->schema([
...$infolist,
Action::make('view')
->label('Bekijk cursus')
->url(fn () => ViewCourse::getUrl(['record' => $course]))
->button(),
]);
})->toArray());
}