据我所知的资源
Route::resource('files', 'FileController');
上述资源将路由以下网址。
资源控制器为您的 Route::resource('files', 'FileController'); 处理的操作很少
Route::get('files',FileController@index) // get req will be routed to the index() function in your controller
Route::get('files/{val}',FileController@show) // get req with val will be routed to the show() function in your controller
Route::post('files',FileController@store) // post req will be routed to the store() function in your controller
Route::put('files/{id}',FileController@update) // put req with id will be routed to the update() function in your controller
Route::delete('files',FileController@destroy) // delete req will be routed to the destroy() function in your controller
上面提到的单个resource 将完成所有列出的routing
除了那些你必须写你的custom route
在你的场景中
Route::group(['prefix' => 'project'], function(){
Route::group(['prefix' => '{project_id}'], function($project_id){
// Files
Route::resource('files', 'FileController');
});
});
domain.com/project/100/files
如果它的get请求将被路由到FileController@index
如果它的post请求将被路由到FileController@store
如果您的“domain.com/project/100/file/56968”更改为“domain.com/project/100/files/56968”(文件到文件),则会发生以下生根...
domain.com/project/100/files/56968
如果是get请求将被路由到FileController@show
如果它是put请求将被路由到FileController@update
如果它是@ 987654341@ 请求将被路由到FileController@destroy
它对你提到的任何其他urls 没有影响
提供,你需要有RESTful Resource Controllers