我的laravel 5项目中有多个路径文件。每个文件都需要使用身份验证中间件。但是,当我尝试从未从这些文件登录的用户请求路由时,我收到此错误:
NotFoundHttpException in RouteCollection.php line 161:
这是其中一个路径文件:
Route::group(['middleware' => 'web'], function () {
Route::auth();
Route::get('/marketplace/', '\App\Http\Controllers\Marketplaces\Controller@index');
});
这是RouteServiceProvider.php文件:
<?php
namespace App\Providers;
use Illuminate\Routing\Router;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to the controller routes in your routes file.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
protected $marketplaceNamespace = 'App\Http\Controllers\Marketplaces\';
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
//
parent::boot($router);
}
/**
* Define the routes for the application.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function map(Router $router)
{
$router->group(['namespace' => $this->namespace], function ($router) {
require app_path('Http/Routes/routes.php');
});
$router->group(['namespace' => $this->marketplaceNamespace], function ($router) {
require app_path('Http/Routes/routes.marketplace.php');
});
}
}