<?php

namespace App\Livewire\Calendar\Modals;

use LivewireUI\Modal\ModalComponent;
use App\Models\Event;

class DayEventsModal extends ModalComponent
{
    public $date;
    public $events = [];

    public function mount($date)
    {
        $this->date = $date;

        $user = auth()->user();

        $this->events = $user->events()
            ->whereDate('starts_at', $date)
            ->orderBy('starts_at')
            ->get();
    }

    public function render()
    {
        return view('livewire.calendar.modals.day-events-modal');
    }
}
