i have a problem in delete an order:
here the form where press on cancel to delete the order:
<form action="{{route('user.orders.delete', $order->id)}}" method="POST"
onsubmit="return confirm('Are you sure?');">
@method('DELETE')
@csrf
<button
type="submit" class="mt-8 mb-4 py-2 px-14 rounded-full
bg-red-900 text-white tracking-widest hover:bg-blue-800
transition duration-200">
Cancel
</button>
</form>
this is my router:
Route::delete('user/orders/delete/{order}', [OrderController::class, 'delete'])->name('user.orders.delete');
OrderController : delete function:
public function delete(Order $order) { try { unlink(public_path().'/storage/orders/files/'.$order->file); $order->delete(); }catch(\Exception $e) { return redirect()->back()-with('status', 'you cannot delete this item');
} return redirect()->back()->with('status', 'product deleted succefully'); }
so when click on the button (cancel) just go to the right url : when 21 is the order id
http://127.0.0.1:8000/user/orders/delete/21
and it is just not found page!!! and nothing deleted!!!