CUSTOM ROUTE IN LARAVEL

Laravel is providing predefine routes like api, channel, console, web.

But in real time we need more from predefine,

like in projects we need admin panel, front end (web), api, etc.

Just for example take admin panel routes in different than predefine routes, ex: admin.php

For that just follow below steps...


Step 1 : Create file in route folder

name it admin.php


Step 2 : Change in service provider

find file in this path : /app/Providers/RouteServiceProvider.php

add new method at end of the class

and add that method in map function for run

class RouteServiceProvider extends ServiceProvider {
    public function map() {
        ...
        $this->mapAdminRoutes();
    }
    protected function mapAdminRoutes() {
        Route::middleware("web")->namespace($this->namespace)->group(base_path("routes/admin.php"));
    }
}

Step 3 : Define routes in new route file

Now we can define our routes in new generated file like below

Route::get("/admin-login", "Auth\AdminController@loginView");