<?php

namespace App\Http\Controllers;

use App\Models\Park;
use Illuminate\Http\Request;
use Illuminate\View\View;

class ParkController extends Controller
{
    /**
     * Display a listing of parks.
     */
    public function index(): View
    {
        return view('parks.index');
    }

    /**
     * Show the form for creating a new park.
     */
    public function create(): View
    {
        return view('parks.create');
    }

    /**
     * Display the specified park.
     */
    public function show(Park $park): View
    {
        // Load relationships for the park detail page
        $park->load([
            'operator',
            'location',
            'areas.rides' => function ($query) {
                $query->orderBy('position')->orderBy('name');
            },
            'areas' => function ($query) {
                $query->orderBy('position')->orderBy('name');
            },
            'photos' => function ($query) {
                $query->orderBy('is_featured', 'desc')->orderBy('created_at', 'desc');
            }
        ]);

        return view('parks.show', compact('park'));
    }

    /**
     * Show the form for editing the specified park.
     */
    public function edit(Park $park): View
    {
        return view('parks.edit', compact('park'));
    }
}
