php - Laravel 5 POST routes to index instead of store -
i working on laravel 5 restful api seems not routing post requests correctly.
this routes.php:
route::group(array('prefix' => 'api/v1'), function() { route::resource('messages', 'incomingmessages'); }); and controller:
class incomingmessages extends controller { public function index() { return "this index"; } public function store() { return "this store"; } public function update() { return "this update"; } } and happens:
- request
get mydomain.com/api/v1/messages/--> index - request
put mydomain.com/api/v1/messages/1--> update - request
post mydomain.com/api/v1/messages/--> this index
this php artisan route:list returns:
- get|head : api/v1/messages : api.v1.messages.index : app\http\controllers\incomingmessages@index
- get|head : api/v1/messages/create : api.v1.messages.create : app\http\controllers\incomingmessages@create
- post : api/v1/messages : api.v1.messages.store : app\http\controllers\incomingmessages@store
- get|head : api/v1/messages/{messages} : api.v1.messages.show : app\http\controllers\incomingmessages@show
- get|head : api/v1/messages/{messages}/edit : api.v1.messages.edit : app\http\controllers\incomingmessages@edit
- put : api/v1/messages/{messages} :api.v1.messages.update ; app\http\controllers\incomingmessages@update
- patch : api/v1/messages/{messages} : app\http\controllers\incomingmessages@update
- delete : api/v1/messages/{messages} : api.v1.messages.destroy : app\http\controllers\incomingmessages@destroy
so, question is:
what missing? why routing index() instead of routing store()?
notes:
- i have disabled "verifycsrftoken" in
kernel.php - i trying requests using chromium plugin "postman".
update:
the problem adding trailing / url. so, instead of using url:
mydomain.com/api/v1/messages/ i tried one:
mydomain.com/api/v1/messages and worked
the problem caused trailing / being added url. so, instead of using url:
mydomain.com/api/v1/messages/
i tried one:
mydomain.com/api/v1/messages
and worked.
i discovered taking @ server's log. how discovered post requests url messages/ redirected.
Comments
Post a Comment