Skip to content

Commit

Permalink
Merge pull request #6450 from pascalbaljet/patch-4
Browse files Browse the repository at this point in the history
[8.x] Added whenHas() and whenFilled() to Request docs
  • Loading branch information
taylorotwell committed Oct 2, 2020
2 parents 13502ec + 75b6109 commit fb7f37c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions requests.md
Expand Up @@ -233,6 +233,12 @@ When given an array, the `has` method will determine if all of the specified val
//
}

The `whenHas` method will execute the given callback if a value is present on the request:

$request->whenHas('name', function ($input) {
//
});

The `hasAny` method returns `true` if any of the specified values are present:

if ($request->hasAny(['name', 'email'])) {
Expand All @@ -245,6 +251,12 @@ If you would like to determine if a value is present on the request and is not e
//
}

The `whenFilled` method will execute the given callback if a value is present on the request and is not empty:

$request->whenFilled('name', function ($input) {
//
});

To determine if a given key is absent from the request, you may use the `missing` method:

if ($request->missing('name')) {
Expand Down

0 comments on commit fb7f37c

Please sign in to comment.