Sharon Haim Pour
Sharon Haim Pour

Reputation: 6713

Laravel 5 - Method Not Allowed on POST

I'm trying to save a backbone model using model.save().

The url I'm trying to send a POST method to is: http://localhost/user
My route is: Route::POST('/user/{user}', 'Dashboard\Dashboard@newUser');

But I get a Method Not Allowed Exception

Can you see what's wrong in my code?

Upvotes: 0

Views: 958

Answers (1)

René Höhle
René Höhle

Reputation: 27295

And you should look at case sensitivity when you look at the documentation.

Route::post('foo/bar', function () {
    return 'Hello World';
});

Its lowercase. Sometimes that can cause problems.

The next thing is that "named routes" looks like the following:

Route::get('user/profile', [
    'as' => 'profile', 'uses' => 'UserController@showProfile'
]);

I haven't tried that in your way but in that way its working.

And the last thing is that you should pass an ID to your route otherwise the route is not correct. in your case /user/1 for example.

https://laravel.com/docs/5.1/routing

Upvotes: 2

Related Questions