Open tabacitu opened 3 years ago
- We should find a way to allow developers to add MULTIPLE media types on one entity, for example "pictures", "attachments", etc. Which should be possible but I don't see how right now before I get it 100% working;
We need to add a collection name instead of using default:
Like this:
public function store(Request $request, MyModel $mymodel)
{
$media = $mymodel->addMedia($request->file('file'))->toMediaCollection('pictures');
return $media->getUrl();
}
Changing javacript as right now it checks for a unique id:
https://github.com/eduardoarandah/medialibrary-dropzone-for-laravel-backpack/blob/master/src/resources/views/fields/medialibrary-dropzone.blade.php#L78
And adding collection name as a parameter for the index
method.
destroy
and sort
uses the id so that doesn't need to change.
I think we can make the package easier to use by taking advantage of custom Backpack Operations.
Basically, instead of having them create a new controller and 4 routes for each entity they want to have media, we could create an operation, say
InteractWithMediaOperation
, which they use on their ProductCrudController, just like they do for the ListOperation, CreateOperation, ReorderOperation, etc.That operation could host both the routes and actions for the field. So something like this:
Todo:
But:
Let me know what you think @eduardoarandah . Happy to help out with this after I figure out what happens in #6 that stops the package from working for me... I'd of course be happier if you make this conversion to Operations because it'd also mean you take a look at the docs on them and can tell me what you think - I feel that's one bit of the docs that I've had zero feedback on, so I'm not sure how clear I've made it. And it's a pity, because Operations are one thing in Backpack 4.0 that I consider groundbreaking, but not many developers use them to their full potential.
Cheers!