Okay, this is how i added media to a custom module on creation.
Note: replace <module_name> with your module name
Add route in apiRoutes.php something that would makes sense for your module dealing with media. Route i created was
get('<module_name>/media/file', ['as' => 'api.<module_name>.media.file', 'uses' => 'MediaController@file']);
<module_name>/Http/Controllers/Api/MediaController.phpadd this as content MediaController.php
Tell asgard that you added apiRoute.php in
return __DIR__ . '/../Http/apiRoutes.php';
<module_name>/Resources/views/admin/media/file-link.blade.phpadd this as content file-link.blade.php this is basically edited file of original Media module copy (we use this only for single(have not done for multiple yet) media on creation after that we'll use Media module) .
Include new media file in your create view (usually
<module_name>/Resources/views/admin/<entity>/create.blade.php), place this where you want your thumbnail and browse button to appear
@include('<module_name>::admin.media.file-link', ['zone' => '<zone_name>'])you can also pass a thumbName if you want anything other than mediaThumb returned along with zone
['zone' => '<zone_name>', 'thumbName' => '<my_custom_thumb_size>']this basically will display media you choose and store its ID.
This step has quite a bit information so i'll try my best to make some sense Once you hit submit you will go to the
storemethod of your controller (assuming you pass all validation in
FormRequest). So in the
storemethod we will gather
zoneIdpassed by our view on creation and manually link media with entity since by this point we will have entityId.
So in your EntityController.php (lets say
<module_name>/Http/Controllers/Admin/GameControll.php) add relevant parts from here <entity>Controller.php, the main thing is to create your entity before and then link it with media module. I'm sure theres some parts that could be done more elegantly, but this is my development code so.
There's many <module_name>, <entity>, <entity_name> etc. so watch out
Post any questions if in case i forgot something or you didn't get me at some point.
After all of this you can follow official documentation for media module, because nothing changes onEdit and so on.