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

eggplantSword's avatar

The GET method is not supported for this route. Supported methods: POST.

I don't know what is happening, everywhere this route is set up is a post route but it takes it as a get route. This route is triggered when clicking on a button this is the code

click method on vue

downloadExcel() {
    this.$inertia.post('/download/', this.country);
},

route in web.php

Route::post('/download', 'FormController@downloadExcel');

controller method

public function downloadExcel($id)
{
    if ($id == null) {
        $items = Form::with('country')->get();
        dd(json_encode($items));
    } else {
        $items = Form::where('country_id', $id)->with('country')->orderByDesc('created_at')->get();
        dd(json_encode($items));
    }
}

I've tried doing composer dumpautoload a couple times and even invalidate cashes / restart also a couple times but this stays as a get request.

How can I fix it?

0 likes
1 reply
eggplantSword's avatar
eggplantSword
OP
Best Answer
Level 9

This is the solution

downloadExcel() {
    this.$inertia.post('/download',
        {country: this.country}
    );
}

Route::post('/download', 'FormController@downloadExcel');

public function downloadExcel(Request $request)
{
    if ($request->country == null) {
        $items = Form::with('country')->get();
        dd(json_encode($items));
    } else {
        $items = Form::where('country_id', $request->country)->with('country')->orderByDesc('created_at')->get();
        dd(json_encode($items));
    }
}

Please or to participate in this conversation.