Skip to content

Spatie Medialibrary incompatibility  #521

@cv-chameleon

Description

@cv-chameleon

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 #515 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions