<?php

namespace App\Livewire;

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

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

    public function mount()
    {
        $this->loadTopUp();  // Load users initially
    }

    public function loadTopUp()
    {
        $this->topUp = collect(json_decode(file_get_contents(storage_path('app/top-up.json')), true));
    }

    public function render()
    {
        return view('livewire.top-up.top-up', [
            'top_up' => $this->topUp,  // Pass all users to the table
        ]);
    }
}