<?php

namespace App\Livewire;

use Livewire\Component;
use Livewire\Attributes\Layout;  // Required for layout declaration

#[Layout('layouts.dashboard')]  // Attribute syntax for Laravel 11
class Station extends Component
{
    public $stations = [];

    public function mount()
    {
        $this->loadStations();  // Load stations initially
    }

    public function loadStations()
    {
        $this->stations = collect(json_decode(file_get_contents(storage_path('app/stations.json')), true));
    }

    public function render()
    {
        return view('livewire.station-locator.station', [
            'stations' => $this->stations,  // Pass all stations to the table
        ]);
    }
}
