HTTP方法
1 | Route::get($url, $callback); |
路由参数
1 | Route::get('user/{id}', function ($id) { |
路由分组
1 | Route::group(['prefix' => 'admin'], function () { |
绑定模型
1 | Route::get('api/users/{user}', function (App\User $user) { |
Resource 格式
1 | Route::resource('photos', 'PhotoController'); |
动作 | URI | 操作 | 路由名称 |
---|---|---|---|
GET | /photos | index | photos.index |
GET | /photos/create | create | photos.create |
POST | /photos | store | photos.store |
GET | /photos/{photo} | show | photos.show |
GET | /photos/{photo}/edit | edit | photos.edit |
PUT/PATCH | /photos/{photo} | update | photos.update |
DELETE | /photos/{photo} | destroy | photos.destroy |
Api路由版本控制
/api/v1/test
1 | Route::group(['prefix' => 'v1', 'namespace' => 'V1'], function () { |