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

[9.x] Fix factory breaking when trying to determine whether a relation is empty #45135

Merged
merged 1 commit into from
Nov 29, 2022
Merged

Conversation

axlon
Copy link
Contributor

@axlon axlon commented Nov 29, 2022

This fixes a bug introduced in #45118. When a model's singular relation is loaded before the model is stored (e.g. in a afterMaking callback). The factory will try to call isEmpty() on it which will cause an error.

BadMethodCallException : Call to undefined method App\Models\OtherModel::isEmpty()

@WendellAdriel
Copy link
Contributor

@axlon that's a nice catch, I didn't expect this since it's something that was not covered in the tests.
I'm not sure if that's mandatory but I would say that adding a test case covering this issue that you fixed would be a good idea.
Also, sorry for the bug introduced with my PR 😅

@taylorotwell taylorotwell merged commit 10a51e6 into laravel:9.x Nov 29, 2022
@axlon axlon deleted the patch-45118 branch November 29, 2022 15:23
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