Hesto/multi-auth

How to automatic routing "/admin" ?

Closed this issue · 1 comments

The package is great! I Love it.

my route in admin.php like this

Route::resource('amenities', 'AmenityController');

when I try in view: {!! route('amenities.show', [$amenity->id]) !!} its error

ErrorException in UrlGenerator.php line 314: Route [amenities.show] not defined.

So I must add admin to {!! route('admin.amenities.show', [$amenity->id]) !!} then it works.

Is there any solutions without add admin keyword to route?

another solution is, create the route in web.php & add middleware.
the code like this

Route::group(['prefix' => 'admin', 'middleware' => 'admin'], function () {
    Route::resource('amenities', 'AmenitiesController');
});
Hesto commented

@ganjarsetia Sure, there is a solution. Go to app\Providers\RouteServiceProvider.php and remove line:

    protected function mapAdminRoutes()
    {
        Route::group([
            'prefix' => 'admin',
            'as' => 'admin.', //<- remove
            'middleware' => ['web', 'admin'],
            'namespace' => $this->namespace,
        ], function ($router) {
            require base_path('routes/admin.php');
        });
    }