Don't understand how array is made in builder

Found solution here K3 Page Builder: accessing files for a gallery, turns out it needs foreach inside blocks/gallery.php

This solution is pretty useless without your original question.

The thing is first I was able to get only partial urls with this code
<?php echo $data->gallery()->toFiles() ?>
it was returning a list of all images:
paslaugos/metalo-apdirbimas/20170331_093114.jpg
paslaugos/metalo-apdirbimas/20180717_182240.jpg
paslaugos/metalo-apdirbimas/20181017_153458.jpg

but I needed full urls.

The reason for this behavior is this magic method in the collection class:

  public function __toString(): string
    {
        return $this->toString();
    }

It returns a string (a list of keys) when you try to echo a collection.

1 Like