Level 10
You have to add implements HasMedia and InteractsWithMedia trait in your cardimages model
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm trying to use the Advanced Nova Media Library package and I have a problem with registration.
I have created a Car and db model in which, among other things, I also register car_images where, with the help of the Nova Media Library, pictures for each car are to be stored.
When I paste the code below into my nova model I get this error: Call to undefined method App\Models\Car::getMedia()
use Spatie\MediaLibrary\Models\Media;
public function registerMediaConversions(Media $media = null)
{
$this->addMediaConversion('thumb')
->width(130)
->height(130);
}
public function registerMediaCollections()
{
$this->addMediaCollection('main')->singleFile();
$this->addMediaCollection('my_multi_collection');
}
/**
* Get the gallery fields for the resource.
*
* @return array
*/
protected function galleryFields()
{
return [
/* Files::make('Single file', 'one_file'), */
Files::make('Multiple files', 'car_images'),
];
}
Can anyone fix me what I'm doing?
Please or to participate in this conversation.