Skip to content

Commit 1811f96

Browse files
committed
Add name alias to RouteRegistrar
1 parent c9c5355 commit 1811f96

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Illuminate/Routing/RouteRegistrar.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ class RouteRegistrar
2929
'get', 'post', 'put', 'patch', 'delete', 'options', 'any',
3030
];
3131

32+
/**
33+
* The attributes that are aliased.
34+
*
35+
* @var array
36+
*/
37+
protected $aliases = [
38+
'name' => 'as',
39+
];
40+
3241
/**
3342
* Create a new route registrar instance.
3443
*
@@ -49,7 +58,7 @@ public function __construct(Router $router)
4958
*/
5059
public function attribute($key, $value)
5160
{
52-
$this->attributes[$key] = $value;
61+
$this->attributes[array_get($this->aliases, $key, $key)] = $value;
5362

5463
return $this;
5564
}

tests/Routing/RouteRegistrarTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ public function testCanRegisterGroupWithMiddleware()
116116
$this->seeMiddleware('group-middleware');
117117
}
118118

119-
120119
public function testCanRegisterGroupWithNamespace()
121120
{
122121
$this->router->namespace('App\Http\Controllers')->group(function ($router) {

0 commit comments

Comments
 (0)