Nova: BelongsToMany select field -> choose Image?
I have following question: In Nova I have 2 models: "Event" and "Asset".
"Event" is a table that holds event information. "Asset" is a custom database table that holds id, title, etc. and an image ( I am using the Image field for that purpose).
Between both tables I have a Many to Many relationship in Laravel and I am using BelongsToMany on both models in Nova.
So far this works very well.
However when I attach an "Asset" to an "Event" I will get a selectbox for the "Asset" entry to choose from. I can set this to be the title or the filename in Nova. However here I would love to have a media library or at least an image preview of the assets where I can pick the asset.
Event.php
public function fields(Request $request)
{
return [
// ...
BelongsToManyField::make('Assets'),
];
}
Here's what it looks like: https://codemuc.de/files/attach_asset.png
I already tried different Nova (and Laravel) Media Library Extensions, however it seems like they all have their own table structure. We need to stick to our custom Assets table.
The only small "workaround" for now is this: https://github.com/Benjacho/belongs-to-many-field-nova (at least this extension gives us the possibility to search within the select box).
I appreciate any ideas :-) Thank you!
Please or to participate in this conversation.