<?php

namespace App\Http\Controllers\User;

use App\Http\Controllers\Controller;
use App\Models\Order;
use Illuminate\Support\Facades\Auth;

class OrderController extends Controller
{
    public function index()
    {
        $orders = Order::where('user_id', Auth::id())
            ->with('pizza')
            ->latest()
            ->get();

        return view('user.orders.index', compact('orders'));
    }

    public function deleteOrder($id)
{
  $order = Order::findOrFail($id);

    // Hapus langsung tanpa pengecekan status
    $order->delete();

    return back()->with('success', 'Pesanan berhasil dihapus.');

}

}
