omnia-digital / livewire-calendar

Laravel Livewire component to show Events in a good looking monthly calendar
MIT License
68 stars 7 forks source link

Can you help me with this error: "Livewire Calendar not correctly configured. Check initial inputs." #26

Closed stojankukrika closed 3 months ago

stojankukrika commented 3 months ago

Hi, Can you help me with this error "Livewire Calendar not correctly configured. Check initial inputs." I have no idea how to fix it :( Do you have a discort or something to get faster help? Here is my component:

`namespace App\Livewire;

use App\Models\TeamEvent; use App\Traits\TeamDateFormatTrait; use Carbon\Carbon; use Carbon\CarbonPeriod; use Illuminate\Support\Collection; use Illuminate\Support\Facades\DB; use Omnia\LivewireCalendar\LivewireCalendar;

class TeamEventsCalendar extends LivewireCalendar { use TeamDateFormatTrait;

public $selectedEvent = null;

public function events(): Collection
{
    $date_from = $this->gridStartsAt->format('Y-m-d H:i:s');
    $date_to = $this->gridEndsAt->format('Y-m-d H:i:s');

    $events = collect();

    return DB::table('team_events')
        ->whereNull('deleted_at')
        ->where('date_from', '>=', $date_from)
        ->where('date_from', '<=', $date_to)
        ->where('team_id', auth()->user()->current_team_id)
        ->select('date_to', 'date_from', 'name', 'id')
        ->orderBy('date_to', 'asc')
        ->get();
}

public function onEventClick($eventId)
{
    $this->selectedEvent = TeamEvent::find($eventId);
}

public function closeEventDetailsModal()
{
    $this->selectedEvent = null;
}

public function updateEvent()
{
    redirect()->route('event.edit', ['event' => $this->selectedEvent]);
}

public function getEventsForDay($day, Collection $events): Collection
{
    return $events->filter(function ($event) use ($day) {
            if (isset($event['start_date']) && isset($event['end_date'])) {
                return Carbon::parse($day)->between($event['start_date'], $event['end_date']);
            } else {
                return Carbon::parse($event['date'])->isSameDay($day);
            }
        });
}

} `

joshtorres commented 3 months ago

I'm not sure why this bug just came up, but I fixed it in the new release #27 Also, no we don't have a discord. All support is done through Github Issues to keep things organized.

stojankukrika commented 3 months ago

Yes, it's fixed now. Tnx a loot for quick fix 👍