Hi I'm working with Laravel 5.3 and I notice that the default Auth routes are registered using Auth::routes();
. Is it possible to encapsulate these routes under a prefix group? Eg:
Route::group(['prefix' => 'admin'], function(){
Auth::routes();
});
Routes Groups are helpful in the situation when you want to apply one attribute to all the routes. Laravel 8 route groups allow you to group all the routes related to your modules. Route group takes an array that can take attributes and callback function.
The name method is used to prefix each route name with some specified string. In the name method, we need to specify the string with a trailing character in the prefix. Let's see an example. In the above code, the name of the route would be admin.users.
We can validate it directly in the route, with “where” parameter: The main part here is ‘where’ => [‘locale’ => ‘ [a-zA-Z] {2}’] where we use a regular expression to match only two-letter combinations. Tip 4. Dynamic Subdomain Routing This comes directly from the official Laravel documentation, but rarely used so I think to mention it.
The prefix method may be used to prefix each route in the group with a given URI. For example, you may want to prefix all route URIs within the group with admin: The name method may be used to prefix each route name in the group with a given string. For example, you may want to prefix all of the grouped route's names with admin.
Yes You can use it but to make sure now you should prefix your url with admin
e.g If previously you access your url like http://localhost/auth/login
Now you should prefix your url with admin before auth like below http://localhost/admin/auth/login
Issue is in your middleware you use auth middleware
Go to App/http/Middleware/Authenicate.php and there go to handle mathod in a class.
There you see return redirect()->guest('auth/login');
please replace it with
return redirect()->guest('admin/auth/login')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With