Support the ongoing development of Laravel.io →
Configuration Input
Last updated 2 years ago.
0

You could use

Route::resource('admin/users', 'UserController');

You catch the query like

Redirect::route('admin.users.show', ['users' => 'name']);
...
public function show($username)
{
Last updated 2 years ago.
0

I'm the type of person who likes grouping routes.. For instance, when I design admin routes.. I usually have the following

Route::group(array('prefix' => 'admin', 'before' => 'user_is_admin'), function(){
    Route::group(array('prefix' => 'users'), function(){
        Route::get('/', array('as' => 'admin.users.index', 'uses' => 'Admin\Users@index'));
        Route::get('create', array('as' => 'admin.users.create', 'uses' => 'Admin\Users@create'));
        Route::post('/', array('as' => 'admin.users.store', 'Admin\Users@store'));

        Route::group(array('prefix' => '{id}', 'before' => 'valid_user'), function(){
            Route::get('/', array('as' => 'admin.users.show', 'uses' => 'Admin\Users@show'));
            Route::get('edit', array('as' => 'admin.users.edit', 'uses' => 'Admin\Users@edit'));
            Route::patch('/', array('as' => 'admin.users.update', 'uses' => 'Admin\Users@update'));
            Route::delete('/', array('as' => 'admin.users.destroy', 'uses' => 'Admin\Users@destroy'));
        });
    });
});

You'd need to create those two filters in this case of use

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

aelmasry aelmasry Joined 23 Oct 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.