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

[5.5] Adds inline eloquent factory states #19060

Merged
merged 2 commits into from
May 5, 2017
Merged

[5.5] Adds inline eloquent factory states #19060

merged 2 commits into from
May 5, 2017

Conversation

jhoff
Copy link
Contributor

@jhoff jhoff commented May 4, 2017

Frequently with eloquent factory states, you only need to change one attribute to a scalar value. You often don't actually need to use Faker at all. This change allows you to simply pass an array as the 3rd argument instead of a closure.

image

Note: this is simply an addition of functionality. Closures still work as expected.

@browner12
Copy link
Contributor

I'm mostly indifferent on this, but personally I don't see enough of a benefit for all the code changes and additions.

BTW, you don't need to pass in Faker, you can do a simple closure if it's not used.

@jhoff
Copy link
Contributor Author

jhoff commented May 4, 2017

Sure, it's mostly a nice to have. When you have a factory that has multiple states, they add up quickly.

@browner12
Copy link
Contributor

this might interest you.

https://github.com/Stydenet/Factory

in regards to this PR

#18829

@jerguslejko
Copy link
Contributor

Once the short closure syntax is available in PHP, this will no longer be a concern.

@jhoff
Copy link
Contributor Author

jhoff commented May 4, 2017

@jerguslejko While you're not wrong, considering the RFC is still 'under discussion', IF it actually makes it into the language, it's still multiple years out. I'm not holding my breath.

@taylorotwell taylorotwell merged commit f38bd37 into laravel:master May 5, 2017
@taylorotwell
Copy link
Member

Seems nice to me.

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.

4 participants