Level 29
You can use $routes = app()->router->getRoutes(); to get the cached routes
Hello everynone,
I'm accessing route list with Route::getRoutes()->get() but when i cache routes with php artisan route:cache it's returns empty array, it returns nothing.
How i list all routes with / while i'm using route:cache?
Thank you
Here is full code :
private function getRoutes(){
$routes = Route::getRoutes()->get();
$groupRoutes = [];
foreach ($routes as $route){
$action = $route->getAction();
if (isset($action['middleware']) && in_array('language', $action['middleware'])){
$groupRoutes[] = $route->getName();
}
}
return $groupRoutes;
}
Please or to participate in this conversation.