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

Set model relation on InteractsWithMedia@loadMedia() #3219

Merged
merged 1 commit into from
Mar 29, 2023

Conversation

cosmastech
Copy link
Contributor

@cosmastech cosmastech commented Mar 28, 2023

If ever media needs to reference its model (for instance, within a Resource), it will have to make a separate DB query to get the relationship (and this is especially annoying if you disable lazy loading).

When loadMedia() is called, it will set the model property for all Media within the Collection.

@freekmurze freekmurze merged commit fbdcba9 into spatie:main Mar 29, 2023
@freekmurze
Copy link
Member

Very neat, thank you!

freekmurze added a commit that referenced this pull request Mar 29, 2023
@freekmurze
Copy link
Member

freekmurze commented Mar 29, 2023

I've reverted this as I have a hunch that this change resulted in errors.

More info here: #3224 (comment)

Should you PR this again, do add a test to see if an media item with an explicitly loaded relation still is serializable.

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.

2 participants