-
Notifications
You must be signed in to change notification settings - Fork 4.8k
[12.x] Be more specific about usage of recycle() #10377
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
Conversation
Be specific about recycle only working for 1-1 and 1-many
@@ -1,4 +1,4 @@ | |||
# Eloquent: Factories | |||
one# Eloquent: Factories |
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.
Are you sure, the "one" is supposed to be there?
For factories that include relationships, you may use the `recycle` method to ensure a single instance of the related model is recycled for all of the relationships created by the factory. | ||
For relationships outside of the factory (like a many-to-many), see [HasAttached()](#pivot-table-attributes). |
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.
Not sure if the first part is needed since we are already on the "Factories" docs page. Furthermore, I'd assume, you would need yet another line break to make Markdown render the second part as a separate paragraph.
Going to skip this one for now. |
@taylorotwell @shaedrich |
I can only speak for myself, but for me, something like this would probably suffice: > [!NOTE]
> For relationships outside of the factory (like a many-to-many), see [HasAttached()](#pivot-table-attributes). |
Thanks, good suggestion! |
Recycle only works for relationships defined inside of the factory.
This PR makes that more clear in the docs, and refers to the hasAttached section for many-to-many relationships.