<?php

namespace App\Http\Controllers;

use App\Models\PosOrder;
use Illuminate\Http\Request;

class TestOrderController extends Controller
{
    public function test()
    {
        $allOrders = PosOrder::withTrashed()->count();
        $activeOrders = PosOrder::count();
        $orders = PosOrder::with(['table', 'waiter', 'items'])->get();
        
        return response()->json([
            'total_orders_including_deleted' => $allOrders,
            'active_orders' => $activeOrders,
            'orders_found' => $orders->count(),
            'orders' => $orders->map(function($order) {
                return [
                    'id' => $order->id,
                    'order_number' => $order->order_number,
                    'status' => $order->status,
                    'created_at' => $order->created_at,
                    'deleted_at' => $order->deleted_at,
                    'has_table' => $order->table ? true : false,
                    'has_waiter' => $order->waiter ? true : false,
                    'items_count' => $order->items->count(),
                ];
            })
        ]);
    }
}

