Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] A resource can define the route basename #16352

Merged
merged 2 commits into from
Nov 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/Illuminate/Routing/ResourceRegistrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,12 @@ protected function getResourceAction($resource, $controller, $method, $options)
*/
protected function getResourceName($resource, $method, $options)
{
if (isset($options['names'][$method])) {
return $options['names'][$method];
if (isset($options['names'])) {
if (is_string($options['names'])) {
$resource = $options['names'];
} elseif (isset($options['names'][$method])) {
return $options['names'][$method];
}
}

// If a global prefix has been assigned to all names for this resource, we will
Expand Down
11 changes: 11 additions & 0 deletions tests/Routing/RoutingRouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,17 @@ public function testResourceRouteNaming()

$this->assertTrue($router->getRoutes()->hasNamedRoute('foo'));
$this->assertTrue($router->getRoutes()->hasNamedRoute('bar'));

$router = $this->getRouter();
$router->resource('foo', 'FooController', ['names' => 'bar']);

$this->assertTrue($router->getRoutes()->hasNamedRoute('bar.index'));
$this->assertTrue($router->getRoutes()->hasNamedRoute('bar.show'));
$this->assertTrue($router->getRoutes()->hasNamedRoute('bar.create'));
$this->assertTrue($router->getRoutes()->hasNamedRoute('bar.store'));
$this->assertTrue($router->getRoutes()->hasNamedRoute('bar.edit'));
$this->assertTrue($router->getRoutes()->hasNamedRoute('bar.update'));
$this->assertTrue($router->getRoutes()->hasNamedRoute('bar.destroy'));
}

public function testRouterFiresRoutedEvent()
Expand Down