Make Factory recycle method to accept the name of the relationship #46873
Unanswered
khalyomede
asked this question in
Ideas
Replies: 1 comment
-
I admit this would be helpful for me as well, but only because the original writers of the software chose to go against the grain, against convention, and did not use the convention dictated name for the relation. In my case, we have several different names for each relation to the same model -- which means I would need multiple names accepted to the recycle method in order to cover all the possibilities. This, to me, is us not being willing/able to refactor our own code rather than needing another feature from the Laravel team. Embrace convention! =) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Context
I currently use factories to propagate my user across various models:
As you can see, I was able to save up some line of code in line 10
But I have failed to recycle the
$user
in line 8 for defining my shopping list author, because I need to define the relationship nameProposal
Allow the
->recycle()
method to take the name of the relationship as second parameter, much like->for()
allows it. This would help me not repeat my code above:What do you think about it?
Beta Was this translation helpful? Give feedback.
All reactions