HITENDRA PATEL

CUSTOM ROUTE IN LARAVEL

Published 4 years ago 1535 Views
image

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");

A BLOG ABOUT DEVELOPMENT

Subscribe and get my latest blog post in your inbox.
image
DIGITAL OCEAN SETUP LARAVEL

Install & configure laravel project into live digital ocean server.

image
LARAVEL PUSH NOTIFICATION

Laravel push notification for devices with FCM

image
INSTALL COMPOSER ON MACOS

Install Composer on MacOS