group接受这几个属性,namespace、prefix、where、as。同时group可以嵌套使用。

以下两段代码功能相同

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
Route::group(['prefix' => 'users', 'namespace' => 'User'], function()
{
Route::post('', [
'as' => '新增用户',
'uses' => 'UserController@store'
]);

Route::get('{id}', [
'as' => '用户详情',
'uses' => 'UserController@show'
])->where(['id' => '\\d+']);
});
?>
1
2
3
4
5
6
7
8
9
10
11
<?php
Route::post('users', [
'as' => '新增用户',
'uses' => 'User\UserController@store'
]);

Route::get('users\{id}', [
'as' => '用户详情',
'uses' => 'User\UserController@show'
])->where(['id' => '\\d+']);
?>