katie hudson
katie hudson

Reputation: 2893

Error with routing

I have a link

<a href="{{ route('projects.postProject', $project->id) }}" class="btn btn-info pull-right" data-token="{{ csrf_token() }}">
    <span class="glyphicon" aria-hidden="true"></span>
    Post Project
</a>

Within my route file I have the following

Route::post('projects/{projects}/postProject', array('as' => 'projects.postProject', 'uses' => 'ProjectController@postProject'));

And within the controller I have this

public function postProject(Project $project)
{
    dd($project);
}

From what I see this is correct. However, I am getting the following

MethodNotAllowedHttpException in RouteCollection.php line 218:

Is there something I am missing here?

Thanks

Upvotes: 0

Views: 24

Answers (3)

Pawel Bieszczad
Pawel Bieszczad

Reputation: 13325

You are using a link to call that route, and that's a GET request. You would need to submit a form in order to create a POST request.

Upvotes: 2

devuser
devuser

Reputation: 136

You using ajax for post? In that case Route::post is correnct.

MethodNotAllowedHttpException means that you trying to use instead post something else

Show me the posting form

Upvotes: 0

devuser
devuser

Reputation: 136

Change Route::post to Route::get

Upvotes: 1

Related Questions