0

If you had defined a RESTful controller in routes.php

Route::controller('users', 'UserController');

and the following functions in the UserController class

public function getLogin() { ... }
public function postLogin() { ... }

Do we even need to define Route::post('user/login', 'UserController@postLogin') anymore?

1 Answer 1

1

Do we even need to define Route::post('user/login', 'UserController@postLogin') anymore?

No - because the RESTful controller route includes that.

You can test this by running php artisan routes to see a list of all registered routes in your application.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks. In my php artisan routes output, I have GET|HEAD user/login/{one?}/{two?}/{three?}/{four?}/{five?} which will be handled by UserController@getLogin. Do I need to take care of the {one?}/{two?}...? Same thing with the PUT entry.
@moey you don't have to worry about those parameter, the ? denotes optional parameter. If you do pass parameter to your controller method, say @getLogin, you can automatically catch the parameter by declaring public function getLogin($anyName) {}
@JofryHS: +1, thanks. So, does it mean getLogin($param1, $param2) will take care of the 2 arguments in /user/login/arg1/arg2?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.