Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Laravel route::controller handle 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 under the impression (and would prefer) the first option, but it's not behaving for me in that way. What should be happening here?

like image 527
Damon Avatar asked Jan 14 '23 06:01

Damon


1 Answers

Laravel 4 uses - to seperate long action names, so in this case your action would look like the following

public function postPasswordReset

and your url's to it would look like

/account/password-reset

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

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

like image 197
clone1018 Avatar answered Jan 17 '23 16:01

clone1018