diff --git a/src/Illuminate/Http/Request.php b/src/Illuminate/Http/Request.php index ce17897aba9c..8ceca8edeb4d 100644 --- a/src/Illuminate/Http/Request.php +++ b/src/Illuminate/Http/Request.php @@ -200,7 +200,7 @@ public function is() */ public function routeIs($name) { - return $this->route() && $this->route()->getName() === $name; + return $this->route() && $this->route()->isName($name); } /** diff --git a/src/Illuminate/Routing/Route.php b/src/Illuminate/Routing/Route.php index de94b09a9e37..989705c4d6ab 100755 --- a/src/Illuminate/Routing/Route.php +++ b/src/Illuminate/Routing/Route.php @@ -591,6 +591,16 @@ public function getName() return isset($this->action['as']) ? $this->action['as'] : null; } + /** + * Checks whether the route's name is equal to a given one. + * @param string $name + * @return bool + */ + public function isName($name) + { + return $this->getName() === $name; + } + /** * Add or change the route name. * diff --git a/src/Illuminate/Routing/Router.php b/src/Illuminate/Routing/Router.php index f70b3611beb4..354ae24d8b81 100644 --- a/src/Illuminate/Routing/Router.php +++ b/src/Illuminate/Routing/Router.php @@ -940,7 +940,7 @@ public function is() */ public function currentRouteNamed($name) { - return $this->current() ? $this->current()->getName() == $name : false; + return $this->current() ? $this->current()->isName($name) : false; } /** diff --git a/tests/Http/HttpRequestTest.php b/tests/Http/HttpRequestTest.php index 201b3f7f59f4..84d96ab59683 100644 --- a/tests/Http/HttpRequestTest.php +++ b/tests/Http/HttpRequestTest.php @@ -157,7 +157,7 @@ public function testIsMethod() $this->assertTrue($request->is('/')); } - public function testIsRouteNameMethod() + public function testRouteIsMethod() { $request = Request::create('/foo/bar', 'GET');