Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ab8b474

Browse files
committed
Properly allow array of route requiremnts.
Signed-off-by: Jason Lewis <[email protected]>
1 parent 4651c39 commit ab8b474

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/Illuminate/Routing/Route.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public function getParameterKeys()
313313
* @param string $expression
314314
* @return \Illuminate\Routing\Route
315315
*/
316-
public function where($name, $expression)
316+
public function where($name, $expression = null)
317317
{
318318
if (is_array($name)) return $this->setArrayOfWheres($name);
319319

tests/Routing/RoutingTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,15 @@ public function testFiltersCanBeDisabled()
373373
}
374374

375375

376+
public function testWhereAcceptsArrayOfRequirements()
377+
{
378+
$router = new Router;
379+
$router->get('/foo/{name}/{age}', function($name, $age) { return $name.$age; })->where(['age' => '[0-9]+']);
380+
$request = Request::create('/foo/jason/22', 'GET');
381+
$this->assertEquals('jason22', $router->dispatch($request)->getContent());
382+
}
383+
384+
376385
/**
377386
* @expectedException Symfony\Component\HttpKernel\Exception\NotFoundHttpException
378387
*/

0 commit comments

Comments
 (0)