Anyone can help me to separate frontend and backend routes in Metronic laravel version?
Thanks !
I tried your version but for now not working. I will try to search for another method.
under routes/frontend create an auth.php file and add:
<?php
Route::group(["middleware" => "guest"], function () {
// Authentication
Route::get("login", [LoginController::class, "showLoginForm"])->name("login");
Route::post("login", [LoginController::class, "login"])->name("login.post");
}); <?php
Route::redirect("/", "/admin/dashboard", 301)->name("redirect"); 
The way i manage separation for frontend and backend routes is as follows:
create a helper:
if (! function_exists("includeFilesInFolder")) {
/**
* Loops through a folder and requires all PHP files
* Searches sub-directories as well.
*
* @param $folder
*/
function includeFilesInFolder($folder)
{
try {
$rdi = new RecursiveDirectoryIterator($folder);
$it = new RecursiveIteratorIterator($rdi);
while ($it->valid()) {
if (! $it->isDot() && $it->isFile() && $it->isReadable() && $it->current()->getExtension() === "php") {
require $it->key();
}
$it->next();
}
} catch (Exception $e) {
echo $e->getMessage();
}
}
}
if (! function_exists("includeRouteFiles")) {
/**
* @param $folder
*/
function includeRouteFiles($folder)
{
includeFilesInFolder($folder);
}
} /*
* Frontend Routes
*/
Route::name("frontend.")->group(function () {
includeRouteFiles(__DIR__."/frontend/");
});
/*
* Backend Routes
*/
Route::prefix("admin")->name("admin.")->middleware("auth")->group(function () {
includeRouteFiles(__DIR__."/backend/");
}); <?php
Route::group(["middleware" => "guest"], function () {
// Authentication
Route::get("login", [LoginController::class, "showLoginForm"])->name("login");
Route::post("login", [LoginController::class, "login"])->name("login.post");
}); <?php
Route::redirect("/", "/admin/dashboard", 301)->name("redirect"); 
Thank you Carlos and appreciate your efforts. Hope this can help others as well 
Thanks
Hi,
You have to customize it. At the moment, Metronic does not have an example for it.
You could also split your admin routes into a separate file, and require that file in your app/routes.php file. With separate route for / and /admin.
Thanks
I tried to customize it, but when i change routes files and get back to initial code:
// Route::get('/', function () {
// return redirect('index');
// });
But when i try this, authentication and menu doesn't work anymore.
I don't know how to handle this:
$menu = theme()->getMenu();
array_walk($menu, function ($val) {
if (isset($val['path'])) {
$route = Route::get($val['path'], [PagesController::class, 'index']);
// Exclude documentation from auth middleware
if (!Str::contains($val['path'], 'documentation')) {
$route->middleware('auth');
}
// Custom page demo for 500 server error
if (Str::contains($val['path'], 'error-500')) {
Route::get($val['path'], function () {
abort(500, 'Something went wrong! Please try again later.');
});
}
}
});
I know how to do this with initial laravel files, but metronic was customized in another way.
Thanks !