Laravel 5: Can't POST to route resource

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company

Laravel Routing Headache: Why POST Requests Fail on Resource Routes

As developers diving into the world of frameworks like Laravel, we often encounter frustrating routing issues, especially when dealing with form submissions and resource controllers. A very common scenario is defining a Route::resource and finding that while the routes seem available via route:list, the actual POST request fails with a MethodNotAllowedHttpException.

This post will diagnose why this happens, explore the common pitfalls in structuring your HTML forms within Laravel applications, and provide the robust solution you need to master routing. We’ll ensure your data flows correctly by understanding the mechanics behind how Laravel maps HTTP methods to routes.

Understanding Route::resource and HTTP Methods

When you define a resource route using Route::resource('projects', 'ProjectsController'), Laravel automatically generates seven distinct routes, each mapped to a specific HTTP method:

  • GET /projects: Maps to index (for listing resources).
  • GET /projects/create: Maps to create (to display the form).
  • POST /projects: Maps to store (to handle the form submission and save data).
  • GET /projects/{project}: Maps to show (to display a single resource).
  • PUT/PATCH /projects/{project}: Maps to update (to update a resource).
  • DELETE /projects/{project}: Maps to destroy (to delete a resource).

Your observation that route:list shows the POST method available for projects.store is correct—Laravel has defined this route correctly in your application's routing file. The error you are encountering during the actual submission stems not from a missing route definition, but usually from an incorrect target specified in your HTML <form> tag.

The Pitfall: Incorrect Form Action Attributes

The core of this issue almost always lies in how you define the action attribute within your HTML form. You mentioned trying different approaches: using an empty string (action="") or using a Blade helper ({{ url('projects/store') }}). While these seem logical, they often fail when dealing with resource routes that require specific URI structures.

When submitting a form, the browser sends the request to the URL specified in the action attribute using the method specified by the method attribute (usually POST). If the route structure defined by Laravel doesn't perfectly align with the URL provided, the router throws a MethodNotAllowedHttpException.

The Correct Approach: Using the route() Helper

The most reliable way to ensure your form targets the correct store method generated by Route::resource is to leverage Laravel’s route helpers. Instead of hardcoding URLs, you should dynamically generate the URL using the route() helper. This ensures that even if your route structure changes (e.g., adding prefixes or middleware), your form remains functional.

Here is how you correctly link a form to the store action:

{{-- Correct way to define the action for form submission --}}
<form method="POST" action="{{ route('projects.store') }}">
    @csrf  {{-- Always include CSRF token for POST requests --}}
    <label for="name">Project Name:</label>
    <input type="text" name="name" id="name">
    <button type="submit">Store Project</button>
</form>

By using route('projects.store'), you instruct Laravel exactly which URI corresponds to the POST request needed to execute the store method defined by your resource route. This practice is foundational when building dynamic interfaces in Laravel, making development significantly more resilient and maintainable. As we discussed on the Laravel documentation, understanding these helpers is key to mastering framework interactions.

Conclusion: Building Resilient Forms

The MethodNotAllowedHttpException when submitting forms against resource routes is rarely a bug in the route definition itself; it’s almost always an issue with how the client (the browser) interacts with that definition via the form's action. Always rely on Laravel’s routing helpers like route() and url() when building dynamic forms. This ensures that your application remains robust, scalable, and adheres to modern development best practices. By implementing this simple fix, you move past frustrating errors and focus on building beautiful applications.