Reputation: 3956
Now I am writing routes like this:
Route::group(['prefix' => 'v2/'], function(){
Route::post('/reg', 'UserController@reg');
Route::post('/login', 'UserController@login');
...
});
Is there any way to make routes like this :
Route::group(['prefix' => 'v2/'], function(){
Route::group(['uses' => 'UserController'], function(){
Route::post('/reg', '@reg');
Route::post('/login','@login');
...
});
});
Upvotes: 1
Views: 1206
Reputation: 3308
You can use Implicit Controllers instead.
Your controller method names should begin with the HTTP verb they respond to followed by the URI you want.
For example: postLogin
method will respond to POST /login
.
Route::controller('v2', 'UserController', [
'postReg' => 'user.reg',
'postLogin' => 'user.login',
]);
Upvotes: 1
Reputation: 7964
Not that I know of, but you could do this
Route::controller('v2', 'UserController');
So now you should have in your controller methods getReg
, and postLogin
and they would be at same routes as you described.
GET /v2/reg -> UserController@getReg
POST /v2/login -> UserController@postLogin
Upvotes: 1