SpatieMediaLibraryImageEntry
I'm trying to use the SpatieMediaLibraryImageEntry with a model that has a belongsTo relationship and seems not to work.
If I use te SpatieMediaLibraryImageEntry in an infolist of a model that implemens HasMedia, it works. It looks for a 'media' relationship and query it for getting the first image associated with the record.
However, and here comes my problem, if I try to use SpatieMediaLibraryImageEntry in a model that have a belongsTo relationship with the model that has the media, it doesn't works.
Suppose that I have the model Post which implements the HasMedia interface. And other model Comment, so posts can have many comments, and a comment belongs to a post.
If I'm not using spatie media library, and post have a column called image, in a post resource/infolist, I can use an ImageEntry::make('image'), and in the case of using spatie media library, it will be SpatieMediaLibraryImageEntry::make('whatever') and the first image will be rendered.
But in a comments infolist where I try to show only one comment and show the post image, without spatie ImageEntry::make('post.image') works, but when using spatie image library SpatieMediaLibraryImageEntry::('post') doesn't works. It looks like that it doens't tries to resolve the post relationship to use it as the record and look for the 'media' relationship in the post record.
I'm start to think that is something that SpatieMediaLibraryImageEntry is not designed to work with. Any idea?
0 Replies