Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error HasMediaTrait->deleteMedia #691

Closed
StApostol opened this issue Aug 2, 2017 · 3 comments
Closed

Fatal error HasMediaTrait->deleteMedia #691

StApostol opened this issue Aug 2, 2017 · 3 comments

Comments

@StApostol
Copy link
Contributor

The example: I try to delete media not related to the model.
This code (https://github.com/spatie/laravel-medialibrary/blob/master/src/HasMedia/HasMediaTrait.php#L376) return null.
So this row https://github.com/spatie/laravel-medialibrary/blob/master/src/HasMedia/HasMediaTrait.php#L379 return the fatal error because $media are not declared as Spatie\MediaLibrary\Media

@freekmurze
Copy link
Member

Do not try to delete media via that function that is not related to the model.

You could delete media directly instead

$media->delete();

@StApostol
Copy link
Contributor Author

StApostol commented Aug 3, 2017

I understand that need to use a different method, but do not use it correctly
MediaCannotBeDeleted :: doesNotBelongToModel which throws out a fatal error

@freekmurze freekmurze reopened this Aug 3, 2017
@freekmurze
Copy link
Member

Got it, I'll take a look at this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants