我在Laravel 5.2上有这样的路由:
Route::group( [ 'prefix' => 'users/{hash}/addresses', 'as' => 'admin.addresses.' ], function () {
Route::get( 'getdata', [ 'as' => 'getdata', 'uses' => 'AddressController@getData' ] );
Route::get( 'create', [ 'as' => 'create', 'uses' => 'AddressController@create' ] );
Route::post( 'create', [ 'as' => 'store', 'uses' => 'AddressController@store' ] );
} );
如何在我的路线组声明中设置我的动作控制器名称?
它假设是这样的:
Route::group( [ 'prefix' => 'users/{hash}/addresses', 'as' => 'admin.addresses.', 'controller' => 'AddressController' ], function () {
Route::get( 'getdata', [ 'as' => 'getdata', 'uses' => 'getData' ] );
Route::get( 'create', [ 'as' => 'create', 'uses' => 'create' ] );
Route::post( 'create', [ 'as' => 'store', 'uses' => 'store' ] );
} );
答案 0 :(得分:0)
您可以使用资源路线。
Route::resource('users/{hash}/addresses/admin.addresses', 'AddressController');
如果您只需索引并创建,则可以像这样指定。
Route::resource('users/{hash}/addresses/admin.addresses', 'AddressController', ['only' => ['index', 'store']]);