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.6] Add alias for calling with single state #24937

Merged
merged 1 commit into from
Jul 23, 2018

Conversation

dwightwatson
Copy link
Contributor

Minor - I know - but I find that when I'm using factory states I'm only ever using a single state at a time. I don't think I've ever used multiple states with a factory. I've tried calling just state() so many times assuming it would work and then realising it doesn't. Also, it just reads better when you're only dealing with a single argument.

// Still works...
$listing = factory(Listing::class)->states('activated')->create();

// Reads better...
$listing = factory(Listing::class)->state('activated')->create();

@browner12
Copy link
Contributor

seems like overkill. isn't your IDE just autocompleting it for you?

@dwightwatson
Copy link
Contributor Author

Not everyone uses an IDE.

I feel like Laravel's syntax has often prioritised readability which is why I thought it was worth suggesting this addition.

@browner12
Copy link
Contributor

suggestions always welcome 😄

but my vote is no, because I don't feel it provides enough of a benefit, or even improves the readability significantly.

@taylorotwell taylorotwell merged commit c8682e1 into laravel:5.6 Jul 23, 2018
@browner12
Copy link
Contributor

I swear to god, if you want something merged, just come ask me to comment on it that I don't like it 😬

@garygreen
Copy link
Contributor

@browner12 haha. Well I swear to god, just now I was writing some unit tests and the amount of times I've done ->state() thinking it should work as I'm just applying one state. Doh. This might seem like syntax sugar, but it's low maintenance and it's worth it. 😄

@browner12
Copy link
Contributor

yah, it's fine. i'm not loosing sleep over this one.

I'm just glad people like 'states', makes me feel good about something I wrote!

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