<?php

namespace App\Http\Controllers;

use App\Models\Appointment;
use Carbon\Carbon;
use Illuminate\Http\Request;

class MonitorController extends Controller
{
    public function index(Request $request)
    {
        $date = $request->query('date', Carbon::today()->toDateString());

        $appointments = Appointment::with(['client', 'barber.user', 'service'])
            ->where('appointment_date', $date)
            ->orderBy('start_time')
            ->get();

        return response()->json($appointments);
    }
}
