M a m a D
M a m a D

Reputation: 2139

Laravel - Access middleware in RouteServiceProvider.php

I need to separate the backend and frontend routes. To do so I created two different files in \routes directory for backend and frontend. In the RouteServiceProvider.php I want to know who the current user is in order to load its routes. I tried this

public function map()
{
    $this->mapApiRoutes();

    $this->mapWebRoutes();

    //
}

protected function mapWebRoutes()
{

    Route::middleware('auth')
         ->namespace($this->namespace)
         ->group(base_path('routes/backend.php'));
}

To load the route for middleware auth but it is not working. How can I do that?

Upvotes: 0

Views: 460

Answers (1)

Add this file to your config folder https://github.com/laravel/laravel/blob/develop/config/logging.php

and add this to your .env file LOG_CHANNEL=stack

PHP artisan config:cache

Upvotes: 1

Related Questions