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

[Proposal] URI Segments for Route::resource #170

Closed
cmenke opened this issue Jan 26, 2013 · 2 comments
Closed

[Proposal] URI Segments for Route::resource #170

cmenke opened this issue Jan 26, 2013 · 2 comments

Comments

@cmenke
Copy link

cmenke commented Jan 26, 2013

The most recent changes to Resource Controllers "broke" the ability to specify URI segments using slashes. Prior to the update, this would work fine:

Route::resource('admin/user', 'Admin\\UserController');

I'm not sure Route::resource was ever intended to be used this way. It might be nice to have a little more control over the URI, though – especially when working on larger projects where it makes sense to prefix URI-segments to differentiate between areas of an app.

In regard to the current implementation in Router.php – and considering that this might not be a common issue – these approaches may also be an option:

// Using a 'uri' Option
Route::resource('user', 'Admin\\UserController', array('uri' => 'admin/user'));

// Using a 'prefix' Option
Route::resource('user', 'Admin\\UserController', array('prefix' => 'admin'));

EDIT: Proposal #181 could be a neat solution to this as well:

Route::group(array('base' => 'admin'), function() {

    // Responds to Request::root() . '/admin/user'
    Route::resource('user', 'Admin\\UserController');

});

Thoughts?

@raftalks
Copy link
Contributor

I am also faced with this issue, as of now, I have removed the forward slash to make it work on my current project, however as it is proposed on #181 which can help sort this resources into a group of resources.

@taylorotwell
Copy link
Member

Can be done using the prefix key in a Route::group.

gonzalom pushed a commit to Hydrane/tmp-laravel-framework that referenced this issue Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants