In this tutorial, we will learn Laravel Get Route:list In Controller
There are three ways to get a route list in the laravel controller method So let's see the bellow example.
Example 1:
use Illuminate\Support\Facades\Route;
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function homePage()
{
$routesList = Route::getRoutes();
dd($routesList);
}
Example 2
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function homePage()
{
$routesList = \Route::getRoutes()->get();
dd($routesList);
}
Example 3
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function homePage()
{
\Artisan::call('route:list');
return \Artisan::output();
}
May this example help you.