在我的前端我有collection
models
。每個collection
可以與後端通信,並且每個model
也可以與後端通信。laravel路線組
我試圖設計一種在這裏正確的URL路徑是什麼,我想
create [POST] /mycollection
update [PATCH] /mycollection/22
delete [DELETE] /mycollection/22
,併爲模特
create [POST] /mycollection/22
update [PATCH] /mycollection/22/3
delete [DELETE] /mycollection/22/3
我應該如何創建我的Laravel路線?
我正在尋找路線組,但它似乎還是相當多的鍋爐板。
Route::group(array('prefix' => 'mycollection'), function()
{
Route::get('{id}', function($id){});
Route::post('/', function(){});
Route::patch('{id}', function($id){});
Route::destroy('{id}', function($id){});
Route::get('{id}/{child_id}', function($id, $child_id){});
Route::post('{id}', function($id){});
Route::patch('{id}/{child_id}', function($id, $child_id){});
Route::destroy('{id}/{child_id}', function($id, $child_id){});
});
你有什麼問題? – ceejayoz
這是做到這一點的正確方式,既RESTful和Laravel? – user391986
您可以使用http://laravel.com/docs/controllers#resource-controllers。 – ceejayoz