I am currently developing a project using laravel 5.0. Lets say i have a route like this in my route.php:
Route::resource('user', 'UserController', ['except' => ['index', 'create', 'store', 'destroy']]);
Route::get('user/{user}/posts', 'UserController@indexUserPosts');
Route::get('user/{user}/changepassword', 'UserController@changePassword');
Route::put('user/{user}/changepassword', 'UserController@update');
Route::patch('user/{user}/changepassword', 'UserController@update');
Where if i access http:// localhost:8000/user/{username}
it will trigger the show method, and if i access http://localhost:8000/user/{username}/edit
it will trigger the edit method which will give a PUT
& PATCH
request to http:// localhost:8000/user/{user}
. But in this phase, the user can only edit their personal informations, for the password i want to create a new editPassword
which gives also PUT
& PATCH
request. And im not sure if i write the route correctly above.
So, the question is how do i manually write the route in the route.php file according to laravel's convention?
And should i send the PUT
& PATCH
request to http: //localhost:8000/user/{user}
again (which i think will crash with the PUT
& PATCH
request from the edit function) or should i send the PUT
& PATCH
request to http: //localhost:8000/user/{user}/changepassword
?
Thanks in advance. :)
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire