【发布时间】:2018-09-07 02:47:05
【问题描述】:
我在 Laravel 5.6 中创建了 2 条路线(web.php 和 admin.php)。
RouteServiceProvider.php:
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
$this->mapAdminRoutes();
}
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
protected function mapAdminRoutes()
{
Route::middleware(['web', 'adminInformation'])
->prefix('manage')
->namespace($this->namespace)
->group(base_path('routes/admin.php'));
}
现在我只需要在admin.php 中获取控制器名称。
例如:
$r = \Route::getRoutes();
foreach ($r as $value) {
echo($value->getName() . "<br />");
}
方法Route::getRoutes()显示所有路由(web.php & admin.php)。
如何仅从admin.php 获取名称控制器?
【问题讨论】: