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.');
}