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

hjortur17's avatar

Not able to redirect after PUT/PATCH request

Hi, I'm trying to update a booking but when I try to redirect back with a flash message I get this error The PUT method is not supported for route dashboard/reservations/edit/53. Supported methods: GET, HEAD.. It looks like it's trying to submit a PUT request to the Redirect::back(). But when I hard-refresh the site, I get the flash message plus the status of the booking get's updated. Any ideas on how to prevent this for happening?

P.S. I'm using Inertia, if that changes anything

Here are my routes:

Route::middleware(['auth', 'can:admin'])->prefix('dashboard')->group(function () {
    Route::prefix('reservations')->group(function () {
        Route::get('', [ReservationController::class, 'index'])->name('dashboard.reservations');
        Route::get('pickup', [ReservationController::class, 'pickup']);
        Route::get('dropoff', [ReservationController::class, 'dropoff']);
        Route::get('create', [ReservationController::class, 'create'])->name('edit.create');
        Route::get('edit/{rental}', [ReservationController::class, 'edit'])->name('edit.rental');

        Route::post('create', [RentalController::class, 'store']);
        Route::put('update', [RentalController::class, 'update']);
        Route::patch('edit', [RentalController::class, 'edit']);
        Route::put('cancel', [RentalController::class, 'destroy']);
    });

	...
});

And here is my controller method:

public function destroy(Request $request)
    {
        $booking = Rental::where('uuid', $request->uuid)->firstOrFail();

        $booking->status = BookingStatusEnum::CANCELLED;

        $booking->save();

        return Redirect::back()->with('success', 'Rental cancelled.');
    }
0 likes
2 replies
hjortur17's avatar
hjortur17
OP
Best Answer
Level 14

Needed to $inertia.patch instead of Axios.

So my request looks like this:

this.$inertia.put("/dashboard/reservations/edit/" + this.updatedBooking.id, {
                    status,
                }, {
                    onSuccess: () => {
                        this.updatedBooking.status = status
                    }
                })
dcx's avatar

@hjortur17 glad you got it fixed...this is a 'just in case' reply, if you're using inertia you'll find this useful for the forms if it's any use.. all methods available inline etc.. https://inertiajs.com/forms

1 like

Please or to participate in this conversation.