$routes = app()->router->getRoutes();
//第一种
foreach ($routes as $k => $value) {
if($value->action['namespace'] == 'App\Http\Controllers\Api') {
$path[$k]['uri'] = $value->uri;
$path[$k]['path'] = $value->methods[0];
}
}
dump($path);
//第二种
$data = [];
$routes = collect($routes)->map(function ($route) use ($data) {
if($route->action['namespace'] == 'App\Http\Controllers\Api') {
$data['uri'] = $route->uri;
$data['path'] = $route->methods[0];
}
return $data;
})->filter()->all();
dump($routes);