<?php

namespace App\Http\Controllers;

use App\Models\Show;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;

class ScheduleController extends Controller
{
    /**
     * Display a listing of active shows for public schedule.
     */
    public function index(): Response
    {
        // Get all active shows, sorted by start_time (upcoming first)
        $shows = Show::where('is_active', true)
            ->orderBy('start_time', 'asc')
            ->get();

        return Inertia::render('Schedule/Index', [
            'shows' => $shows,
        ]);
    }

    /**
     * Display the specified show.
     */
    public function show(Show $show): Response
    {
        // Only show active shows to public
        if (!$show->is_active) {
            abort(404);
        }

        return Inertia::render('Schedule/Show', [
            'show' => $show,
        ]);
    }
}

