Skip to content

[5.6] Add filledAny method to Request#23499

Merged
taylorotwell merged 3 commits into
laravel:5.6from
timacdonald:filled_any_method
Mar 12, 2018
Merged

[5.6] Add filledAny method to Request#23499
taylorotwell merged 3 commits into
laravel:5.6from
timacdonald:filled_any_method

Conversation

@timacdonald

Copy link
Copy Markdown
Member

Currently to determine if the request has any filled values of a list of inputs, you do something like this:

if ($request->filled('disk') || $request->filled('site')) {
    //
}

This allows you to check if the request has filled values for any of the keys - similar to the existing hasAny.

if ($request->filledAny($filters)) {
    //
}

Although $request->filled($keys) accepts an array, it checks to determine if all the keys exist rather than any.

@JayBizzle

Copy link
Copy Markdown
Contributor

FYI, previously proposed here #21388

@ntzm

ntzm commented Mar 12, 2018

Copy link
Copy Markdown
Contributor

I think anyFilled is a better method name than filledAny, thoughts?

@taylorotwell taylorotwell merged commit 5403d02 into laravel:5.6 Mar 12, 2018
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