-
Notifications
You must be signed in to change notification settings - Fork 20
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
Support relations stack & foreign relations #51
Support relations stack & foreign relations #51
Conversation
Hey, thanks a lot for the good PR 👍 Here my feedback to the open points:
What are the things we still need to consider?
See review comment.
You mean that we get rid of the method name when using the "with" method? That as also on my list. would be cool to add that but it would be a breaking change since we cannot make it optional since the "times" variable comes afterwards. 🤔
That's a good question. When we only have the "with" method and not the "withAnd" I would assume as the user that relations would be stacked, so in your example that would be 4 ingredients. |
64b4305
to
bb36f22
Compare
Hey,
That was not very clear in the PR description :)
The relations are now stacking. |
bb36f22
to
912672d
Compare
912672d
to
e53737f
Compare
I pushed a new version with a more consistent make behaviour.
In this test, the |
Thanks, looks good to me. For me this would be the expected behavior for |
src/BaseFactory.php
Outdated
@@ -74,13 +65,21 @@ public function times(int $times = 1): MultiFactoryCollection | |||
})); | |||
} | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the docBlock. I saw some other methods have them now too, but probably due some other PRs. I prefer not
to use them when using types for parameters and the return.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Phpdoc @return $this
is needed to help the IDE autocomplete. The static
return type keyword will be introduced in PHP 8 and will fill the gap with self.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you prefer if I only use /** @return static */
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I tested, I was indeed using VSCode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so if it helps with auto-completing in VS code, we can keep it. For PhpStorm I know that the hinted return type self does work currently as long as there is not "static" return type yet.
e50b8c2
to
27269c8
Compare
So I think we are good then to merge it, anything missing in your opinion? |
Do you think we should update the readme to document the new behaviour of the |
Oh yeah definitely. Can you adapt it and I will check then? |
27269c8
to
783c86f
Compare
Done! Is it ok for you @christophrumpel? |
783c86f
to
12184f5
Compare
Thanks a lot @shaffe-fr. It took us some time but I think we made it :-) Great improvement. |
I just pushed a new release |
Thanks! Glad I could help! |
Hi,
This PR allows to create many related models at once. It also add support of BelongsTo and MorphTo relationship.
To prevent a BC, the relation stack is reset every time
with
is called.With this implementation, the same relation doesn't add up and only the last o
Here are some things that can be improved:
make
creation type,What do you think about this @christophrumpel?