Laravel 8 路由命名

2021-07-16 17:55 更新

路由命名可以方便地為指定路由生成 URL 或者重定向。通過(guò)在路由定義上鏈?zhǔn)秸{(diào)用 name 方法可以指定路由名稱:

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

你還可以指定控制器行為的路由名稱:

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

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

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)