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
Merged

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

merged 4 commits into from
Oct 18, 2019

Conversation

TitasGailius
Copy link
Contributor

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')) {
    //
}

@taylorotwell taylorotwell merged commit 91553d8 into laravel:6.x Oct 18, 2019
@taylorotwell
Copy link
Member

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

@Korko
Copy link

Korko commented Oct 24, 2019

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

@mpryvkin
Copy link

mpryvkin commented Oct 24, 2019

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

@TitasGailius
Copy link
Contributor Author

TitasGailius commented Oct 25, 2019

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

@TheNewSound
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants