Open mateusgalasso opened 3 years ago
You need to make it without a return type (You just miss the :void after the function name).
`public function registerMediaCollections(): void { $this->addMediaCollection('my-collection') //add options ...
// you can define as many collections as needed
$this->addMediaCollection('my-other-collection')
//add options
...
}`
Hey @stonkeep I just ran into this issue myself, the reason it wasn't working for me is that I'd forgotten the implements HasMedia
interface on my model.
worse. it's just there in the documentation.
Help
I'm getting this error, when I'm loading the resource detail page
Spatie\MediaLibrary\MediaCollections\MediaRepository::getCollection(): Argument #1 ($model) must be of type Spatie\MediaLibrary\HasMedia, App\Models\CoordenadorPedagogico given, called in /var/www/html/vendor/spatie/laravel-medialibrary/src/InteractsWithMedia.php on line 290
I'm using
use InteractsWithMedia;
traitHelp