laravel 路由
创建路由分类文件admin.php
在app\Providers 下RouteServiceProvider.php
参照protected function mapWebRoutes(){}方法添加admin路由
新增路由
protected function mapAdminRoutes()
{
Route::middleware('web')
->namespace($this->namespace.'\Admin')
->group(base_path('routes/admin.php'));
}
在map()方法中添加新增mapAdminRoutes()
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
//新增
$this->mapAdminRoutes();
//
}
路由使用
用::必须引入控制器
use App\Http\Controllers\Admin\IndexController;//引入否则找不到控制器
Route::get('admin',[IndexController::class,'index']);
用@则不用引入控制器
Route::get('admin','IndexController@index');

浙公网安备 33010602011771号