whitecube / nova-flexible-content

Flexible Content & Repeater Fields for Laravel Nova
MIT License
778 stars 230 forks source link

Spatie Medialibrary incompatibility #521

Open cv-chameleon opened 1 week ago

cv-chameleon commented 1 week ago

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