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

Updated doc block for $media->model_id #3369

Merged
merged 1 commit into from
Sep 5, 2023

Conversation

viirre
Copy link
Contributor

@viirre viirre commented Sep 5, 2023

The change made in https://github.com/spatie/laravel-medialibrary/pull/3341/files#diff-8adff69d13774eb09fba1b9b993d0be0d466cf8d43523c9d8050884207cd5901R38 breaks our Larastan checks.

We use strict comparison checks between the $media->model_id and an integer (eg: $media->model_id === $model->id) and since the doc block in the above PR says it's a string only, it breaks. But that column can of course also be an integer, so I guess that this was just missed in the PR.

This PR updates the doc block to be @property string|int instead.

@freekmurze freekmurze merged commit e04cd80 into spatie:main Sep 5, 2023
1 check passed
@freekmurze
Copy link
Member

Thanks!

@viirre viirre deleted the viirre-media-typehint branch September 5, 2023 08:44
@francoism90
Copy link
Contributor

francoism90 commented Sep 5, 2023

@viirre Instead of doing this by model_id, you can use the following:

$media = Media::first();

$media->model()->is($model);

See https://laravel.com/docs/10.x/eloquent#comparing-models

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

Successfully merging this pull request may close these issues.

3 participants