Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

trondhuso's avatar

The dreaded The GET method is not supported for route ...

I'm working on this web app where I have a search field and some dropdown buttons with checkboxes and what nots. without doing anything, the app shows the items we have in the database in a table

Based on what you do with the checkboxes, the number of items in the table gets fewer. Without doing anything, the pagination works nicely. But if I check a checkbox or write something in the search-field, I am told that the route expects post.

I have a feeling it tries to post - with the values from the boxes, and not get.

Although, normal behaviour for a search field would really be get and not post.

Anyway: Read a bunch of posts on this, but not really seeing anything that I haven't tried.

0 likes
4 replies
LaryAI's avatar
Level 58

The issue you're encountering is likely due to the form method being set to POST instead of GET. For search functionality, it's common to use the GET method so that the search parameters are included in the URL, making it easy to bookmark or share the search results.

Here's how you can modify your form to use the GET method:

  1. Change the Form Method: Ensure your form is using the GET method. This will append the form data to the URL as query parameters.

  2. Update the Route: Make sure your route is set up to handle GET requests.

Here's an example of how you might set up your form and route in a Laravel application:

Form Example

<form action="{{ route('your.search.route') }}" method="GET">
    <input type="text" name="search" placeholder="Search...">
    <input type="checkbox" name="filter1" value="value1"> Filter 1
    <input type="checkbox" name="filter2" value="value2"> Filter 2
    <button type="submit">Search</button>
</form>

Route Example

In your web.php (or routes file), ensure you have a route that accepts GET requests:

Route::get('/search', [YourController::class, 'search'])->name('your.search.route');

Controller Example

In your controller, handle the search logic:

public function search(Request $request)
{
    $query = YourModel::query();

    if ($request->has('search')) {
        $query->where('column_name', 'like', '%' . $request->input('search') . '%');
    }

    if ($request->has('filter1')) {
        $query->where('filter_column', $request->input('filter1'));
    }

    if ($request->has('filter2')) {
        $query->where('another_filter_column', $request->input('filter2'));
    }

    $results = $query->paginate(10);

    return view('your.view', compact('results'));
}

Summary

  • Ensure your form uses the GET method.
  • Update your routes to handle GET requests.
  • Adjust your controller logic to process the search and filter parameters.

By following these steps, your search functionality should work as expected with the GET method, and you should no longer encounter the error related to unsupported methods.

tykus's avatar

Very difficult to diagnose without seeing your code. Since you are clicking checkboxes and typing to change the results, can we assume there is JS involved?

trondhuso's avatar

Hi all,

I could've posted code. I thougth I was on LW3, but I was on LW2. When I upgraded to LW3, the problem went away.

There was livewire involved that stored the information. I tried everything from adding to an array / listeners and what not. Some worked, some didn't.

1 like

Please or to participate in this conversation.