Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

anon160124's avatar

Advanced Nova Media Library

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?

0 likes
1 reply
swapnilnandgave's avatar

You have to add implements HasMedia and InteractsWithMedia trait in your cardimages model

Please or to participate in this conversation.