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] Prevent test issues with relations with the $touches property #45118

Merged
merged 4 commits into from
Nov 28, 2022

Conversation

WendellAdriel
Copy link
Contributor

As discussed on #45064 this is a change that will prevent the issue of an empty relationship when testing models with the $touches property defined.

TBH IDK if this is the expected behaviour so if this is not the best solution, feel free to close the PR or let me know what should I change so the PR can be accepted.

@taylorotwell taylorotwell merged commit 99aede0 into laravel:9.x Nov 28, 2022
@axlon
Copy link
Contributor

axlon commented Nov 29, 2022

@taylorotwell @WendellAdriel this PR breaks factories, it assumes a relation can only ever be a collection, but it can also be a single model.

This results in errors like:

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

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.

Relationship is empty after using hasAttached() with model that $touches its parent
3 participants