jeremykenedy / laravel-users

A Users Management Package that includes all necessary routes, views, models, and controllers for a user management dashboard and associated pages for managing Laravels built in user scaffolding. Built for Laravel 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 6.0, 7.0 and 8.0.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Changing the route URL?

milanchheda opened this issue · comments

Instead of /users, can we have the configuration or a way to change it to /admin/users?

@jeremykenedy I came here to ask this same question and wanted to check with you about why it was closed? I looked through the code and it wouldn't be tough. I can PR it if you would like.

  • New config setting: routePrefix (default to null or an empty string)
  • Change src/routes/web.php to this:
Route::group([
    'middleware' => 'web',
    'namespace'  => 'jeremykenedy\laravelusers\app\Http\Controllers',
    'prefix'     => config('laravelusers.routePrefix'),
], function () {
    Route::resource('users', 'UsersManagementController', [
        'names' => [
            'index'   => 'users',
            'destroy' => 'user.destroy',
        ],
    ]);

    Route::middleware('auth')->group(function () {
        Route::post('search-users', 'UsersManagementController@search')->name('search-users');
    });
});

One issue with this change is that it requires any routes not generated by route() that are output in views to be changed, but there's only around 10 or so and wouldn't be difficult to update.

As far as potential issues with previous versions, anybody that has published the view files and wants to use a different route prefix would have to manually change the URLs. Anybody that hasn't published the view files or doesn't want to use a different route prefix shouldn't have any issues.