是否有任何干净的方法来隔离管理路由? :laravel 5.1

My code is below in Routes.php

Route::group([
    'middleware' => 'auth',
], function() {

    Route::get('/Categories-List', 'Category_Controller@index');
    Route::get('/Create-Category', 'Category_Controller@create');
    Route::post('/SaveCategory', 'Category_Controller@store')->middleware(['isAdmin']);
    Route::post('/UpdateCategory', 'Category_Controller@update')->middleware(['isAdmin']);
});

What's the problem ?

There are still other 100s of routes defined which contains many belongs to admin.

Is there any clean way to isolate the admin routes ?

You can nest route groups:

Route::group([
    'middleware' => 'auth',
], function() {

    Route::get('/Categories-List', 'Category_Controller@index');
    Route::get('/Create-Category', 'Category_Controller@create');

    Route::group([
        'middleware' => 'isAdmin',
    ], function() {
        Route::post('/SaveCategory', 'Category_Controller@store');
        Route::post('/UpdateCategory', 'Category_Controller@update');
    });
});

You could also put the admin routes in an entirely separate file via app/Providers/RouteServiceProvider.php (add another line like the existing require app_path('Http/routes.php');).

I bumped into this last week and starred it on github. You can use this Laravel package (Laravel-context) to separate your admin context all together.

Let's say you have 2 contexts in your application: an Administration Panel and a RESTful WebService. This are certainly two completely different contexts as in one context you'll maybe want to get all resources (i.e. including trashed) and in the other one you want only the active ones.

This is when Service Providers come in really handy, the only problem is that Laravel doesn't come with an out of the box solution for loading different Service Providers for different contexts.

This package gives you the possibility to register your different repositories to a single interface and bind them through your Context's Service Provider, using Laravel's amazing IoC Container to resolve which concrete implementation we need to bind depending on which context we are on.

Thanks,

Karmendra