W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
命名路由讓你更方便于產(chǎn)生 URL 與重定向特定路由。您可以用 as 的數(shù)組鍵值指定名稱給路由:
Route::get('user/profile', ['as' => 'profile', function()
{
//
}]);
也可以為控制器動作指定路由名稱:
Route::get('user/profile', [
'as' => 'profile', 'uses' => 'UserController@showProfile'
]);
現(xiàn)在你可以使用路由名稱產(chǎn)生 URL 或進(jìn)行重定向:
$url = route('profile');
$redirect = redirect()->route('profile');
currentRouteName 方法會返回目前請求的路由名稱:
$name = Route::currentRouteName();
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: