Skip to content

Commit

Permalink
support dot notation in Request::exists() to fix laravel#14643 (larav…
Browse files Browse the repository at this point in the history
  • Loading branch information
themsaid authored and tillkruss committed Aug 30, 2016
1 parent 6f4d59d commit cf8065c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public function exists($key)
$input = $this->all();

foreach ($keys as $value) {
if (! array_key_exists($value, $input)) {
if (! Arr::has($input, $value)) {
return false;
}
}
Expand Down
7 changes: 7 additions & 0 deletions tests/Http/HttpRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ public function testExistsMethod()
$request = Request::create('/', 'GET', ['foo' => '', 'bar' => null]);
$this->assertTrue($request->exists('foo'));
$this->assertTrue($request->exists('bar'));

$request = Request::create('/', 'GET', ['foo' => ['bar' => null, 'baz' => '']]);
$this->assertTrue($request->exists('foo.bar'));
$this->assertTrue($request->exists('foo.baz'));
}

public function testHasMethod()
Expand All @@ -220,6 +224,9 @@ public function testHasMethod()
//test arrays within query string
$request = Request::create('/', 'GET', ['foo' => ['bar', 'baz']]);
$this->assertTrue($request->has('foo'));

$request = Request::create('/', 'GET', ['foo' => ['bar' => 'baz']]);
$this->assertTrue($request->has('foo.bar'));
}

public function testInputMethod()
Expand Down

0 comments on commit cf8065c

Please sign in to comment.