Working with collections

If you have different types of files that you want to associate, you can put them in their own collection.

$newsItem = News::find(1);

All media in a specific collection can be retrieved like this:

// will return media instances for all files in the images collection

// will returns media instance for all files in the downloads collection

A collection can have any name you want. If you don't specify a name, the file will be added to a collection named default.

You can clear out a specific collection by passing the name to clearMediaCollection: