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 tonull
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.