You can use the media uploaded in any module you make.
Lets say you have an articles module, and want your article to have a cover image. This is when you'll want a 'one-to-one' relation type. If for instance you have a product, which can have multiple images, you'll want a 'one-to-many' relation type.
It is important to note that both types use the same morphToMany relation behind the scenes. It's only the UI which changes.
One to one relation
Like the introduction said, this type of relation is for when you only need one file/image for a particular entity. In addition to this, the image can have a zone given. To stay consistent, using the Article module, example from the introduction, that cover image will have a zone of coverimage.
That way we can easily get the cover image for a particular article.
First thing you need is add the Modules\Media\Support\Traits\MediaRelation trait onto your desired entity (an eloquent model).
This will add a files morphToMany relation onto your entity.
From here you could already start implementing your own field to select a file from the media module, or you can include the partial.
Include the partial
On create views you can follow the following easy steps:
Insert the media::admin.fields.new-file-link-multiple partial like so:
This partial is mostly used to display and link images.
Getting the thumbnail from controller
The final step is to get the thumbnail from the controller so it can be displayed on the object if there is already a file linked to that object. If you're using the partial from the second step, this would be to display the linked image.
You can inject the FileRepository into your constructor or method and use the findFileByZoneForEntity method to get your image. This methods has two parameters, the zone name (string) and the entity (object) it needs to search on.