W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
通常,并不完全需要在 URI
中同時擁有父 ID 和子 ID ,因為子 ID 已經(jīng)是唯一的標(biāo)識符。當(dāng)使用唯一標(biāo)識符(如自動遞增的主鍵)來標(biāo)識 URI
中的模型時,可以選擇使用「淺嵌套」的方式定義路由:
Route::resource('photos.comments', CommentController::class)->shallow();
上面的路由定義方式會定義以下路由:
HTTP 方式 | URI | 行為 | 路由名稱 |
---|---|---|---|
GET | /photos/{photo}/comments
|
index | photos.comments.index |
GET | /photos/{photo}/comments/create
|
create | photos.comments.create |
POST | /photos/{photo}/comments
|
store | photos.comments.store |
GET | /comments/{comment}
|
show | comments.show |
GET | /comments/{comment}/edit
|
edit | comments.edit |
PUT/PATCH | /comments/{comment}
|
update | comments.update |
DELETE | /comments/{comment}
|
destroy | comments.destroy |
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: