Radical Design Course by Jack McDade

From the creator of Statamic

Learn how to make your websites standout and be remembered.

This course is the most refreshing take on teaching design that I've come across.

— Mikaël Sévigny, Developer

Collection Repository

To work with the with Collection Repository, use the following Facade:

use Statamic\Facades\Collection;


Methods Description
all() Get all Collections
find($id) Get Collection by id
findByHandle($handle) Get Collection by handle
findByMount($mount) Get Collection by mounted entry id
findOrFail($id) Get Collection by id. Throws a CollectionNotFoundException when the collection cannot be found.
handleExists($handle) Check to see if Collection exists
handles() Get all Collection handles
queryEntries() Query Builder for Entries
whereStructured() Get all Structured Collections
make() Makes a new Collection instance
Hot Tip!

The id is the same as handle while using the default Stache driver.


While the Collection Repository does not have a Query Builder, you can still query for Entries inside Collections with the queryEntries method. This approach can be useful for retrieving Entries with an existing Collection object.

$blog = Collection::find('blog');

When a collection can't be found, the Collection::find() method will return null. If you'd prefer an exception be thrown, you may use the findOrFail method:



Start by making an instance of a collection with the make method. You can pass the handle into it.

$collection = Collection::make('assets');

You may call additional methods on the collection to customize it further.

->routes('/blog/{slug}') // a string, or array of strings per site
->mount('blog-page') // id of an entry
->sites(['one', 'two']) // array of handles
->cascade($data) // an array
->searchIndex('blog') // index name
->defaultPublishState('published') // or 'draft'
->structureContents($structure) // an array
->sortField('field') // the field to sort by default
->sortDirection('asc') // or 'desc'
->taxonomies(['tags']) // array of handles
->propagate(true); // whether newly created entries propagate to other sites

Finally, save it.

HR: Section
Learn More!

There is more to learn more in these related articles:



HR: Section
Docs feedback

Submit improvements, related content, or suggestions through Github.

Betterify this page →