nova-flexible-content icon indicating copy to clipboard operation
nova-flexible-content copied to clipboard

Spatie Medialibrary incompatibility

Open cv-chameleon opened this issue 1 year ago • 0 comments

Due to the change in Spatie Medialibrary https://github.com/spatie/laravel-medialibrary/releases/tag/11.4.3 where the GetMediaModel function is added on the HasMedia trait, this package is no longer compatible with it.

You've succesfully updated your package to no longer have the collision with this function, by renaming GetMediaModel in your HasMediaLibrary Concern. But this function still calls GetMediaModel on the Layout class, while this function name can no longer be used in this context, because it expects a String as return, while it should return a HasMedia instance.

if you update getMediaModel to for example:

$model = $model->getCustomMediaModel();

and then in the Layout class:

 public function getCustomMediaModel()
    {
        return $this->model;
    }

it doesn't throw errors in the front anymore, but I know get another error in the nova admin

Call to a member function getMedia() on null

edit: this error in Nova was fixed by applying this https://github.com/whitecube/nova-flexible-content/issues/515#issuecomment-2144470536

cv-chameleon avatar Jun 30 '24 08:06 cv-chameleon