Inheritance: DataCollection > Illuminate\Support\Collection


An AssetCollection is used to hold a collection of Asset objects.

This is not to be confused with an AssetContainer, which is the “source” where assets and folders are located.

The examples on this page use simple values to make things easier to understand.

Creating a Collection

You can create an AssetCollection in a similar fashion to a DataCollection or a regular collection.

$collection = collect_assets([1, 2, 3]);

Available Methods

Just like regular collections, the following methods can be chained for fluent manipulation of the underlying array.

To Array

This is just like a DataCollection’s toArray method, except if any assets do not have corresponding files, they will be filtered out from the array.

Import using:

use Statamic\Data\Entries\AssetCollection