Select fields to output on $collection→toArray()

Trying to fetch data from my-plugin/index.php to use in my Component.vue.

Unfortunately I would like to remove some of the fields and add others that are missing. How would I do this?

Thank you

// index.php
'my_grid' => [
  'props' => [
    'pagesData' => function($pagesData = []) {
      return pages('my-page')→children()→toArray();
...

Sure there’s a more elegant way. But for now it’s working and maybe someone will search for this in the future…

'pagesData' => function($pagesData = []) {
                    $formattedData = page('my-page')->children()->toArray(
                        function ($page) {
                            $data = $page->toArray();
                            
                            $data['panelImage']['url'] = $page->getThumbImage()?->thumb('card_panel')->url();
                            unset($data['files']);
                            unset($data['children']);
                            
                            return $data;
                        }
                    );
                    
                    return $formattedData;
                },