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

[6.x] Add "missing" method to Request class #30320

Merged
merged 4 commits into from Oct 18, 2019

Conversation

@TitasGailius
Copy link
Contributor

TitasGailius commented Oct 17, 2019

Just a simple method to check if a given key(s) is missing in the request object.

Instead of doing

if (! $request->has('foo')) {
    //
}

you could do

if ($request->missing('foo')) {
    //
}
TitasGailius and others added 2 commits Oct 18, 2019
@taylorotwell taylorotwell merged commit 91553d8 into laravel:6.x Oct 18, 2019
1 of 2 checks passed
1 of 2 checks passed
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/styleci/pr The analysis has passed
Details
@taylorotwell

This comment has been minimized.

Copy link
Member

taylorotwell commented Oct 18, 2019

Might be worth PRing the laravel/docs repository to document this. Thanks.

@TitasGailius TitasGailius deleted the TitasGailius:request-missing-method branch Oct 18, 2019
@Korko

This comment has been minimized.

Copy link

Korko commented Oct 24, 2019

Shouldn't it be "misses" instead of "missing" to respect the same naming system as "has"?

@mpryvkin

This comment has been minimized.

Copy link

mpryvkin commented Oct 24, 2019

Maybe it should have been called doesntHave similar to whereHas/whereDoesntHave?

@TitasGailius

This comment has been minimized.

Copy link
Contributor Author

TitasGailius commented Oct 25, 2019

I think missing is fine. We can already do cache()->missing($key).

@TheNewSound

This comment has been minimized.

Copy link

TheNewSound commented Nov 10, 2019

I think its ridiculous to make a separate method for 'missing()'. Totally unnecessary overhead. Increases laravel's size, documentation and project code becomes less 'unified' because of different syntax possibilities for exactly the same thing.

If the programmer wants the opposite of has(), its up to him to type !has()
Its faster and cleaner and shorter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.