What are Routes
Routes are define as where we register our application urls or we also define it as it is a path or bridge that connects our frontend with backend like whenever we sends data from frontend it goes to backend with the help of route as in route file we mention our all url's along with backend functions .
Register new route
For registering new route we simply create a file routes/admin.php , here for example we are using admin.php as our new route file you can use any appropriate route according to your requirment, as in our new route file we want all the same properties as in web.php file.
code for admin.php
Register route in RouteServiceProvider
As we create our new route routes/admin.php and now we register our route in app/Providers/RouteServiceProvider.php to register our new route so that our laravel application give access to our new route.
code for RouteServiceProvider :
As shown we register our admin.php file with the prefix of admin that means our our url inside admin.php will be call by prefix admin/ like we have to call home url then we will call with admin/home Now after register our route in RouteServcieProvider as to provide similar properties with the web.php we will also register in app/Http/Kernel.php.
Register route in Kernel
Main reason for register route in app/Http/Kernel.php to provide the same middleware properties as of web.php as in kernel you can also provide the custom middleware as it will apply on all the routes in admin.php .
code for kernel.php :
Output