How does the Laravel :: controller handle the camel / snake case?

in routes.php:

Route::controller('account', 'AccountController'); 

in ajax controller β†’:

 POST /account/password_reset -> postPasswordReset //not working POST /account/passwordReset -> postPasswordReset //not working POST /account/password_reset -> postPassword_reset //not working POST /account/passwordreset -> postPasswordreset //working 

I was impressed (and preferred) the first option, but it does not behave like that. What is going to happen here?

+4
source share
1 answer

Laravel 4 uses - to separate the names of long actions, so in this case your action will look like this

 public function postPasswordReset 

and your url will look like

 /account/password-reset 

However, I recommend using one of the built-in helpers of the router’s URL, for example HTML::linkAction() , URL::action() or if you use a form, simply specify 'action' => ' YourController@YourAction '

Docs: http://laravel.com/docs/html#opening-a-form

+8
source

Source: https://habr.com/ru/post/1483620/


All Articles