<?php

namespace App\Livewire;

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

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

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

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

    public function render()
    {
        return view('livewire.promotion.promotion', [
            'promotions' => $this->promotions, 
        ]);
    }
}
