阅读(3319) (0)

Laravel 8 路由命名

2021-06-23 11:57:02 更新

路由命名可以方便地为指定路由生成 URL 或者重定向。通过在路由定义上链式调用 name 方法可以指定路由名称:

Route::get('user/profile', function () {
    //
})->name('profile');

你还可以指定控制器行为的路由名称:

Route::get('user/profile', [UserProfileController::class, 'show'])->name('profile');

注意:路由命名必须是唯一的