omnia-digital / livewire-calendar

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

Why I have no calendar in browse ? #29

Closed sergeynilov closed 1 month ago

sergeynilov commented 2 months ago

In laravel 10 app / livewire/livewire 3.4.10 I added omnia-digital/livewire-calendar 3.1 and following docs at github I tried to create a calendar with comnponent app/Livewire/AppointmentsCalendar.php:

<?php

namespace App\Livewire;

use Carbon\Carbon;
use Illuminate\Support\Collection;
use Livewire\Component;
use Omnia\LivewireCalendar\LivewireCalendar;

class AppointmentsCalendar extends LivewireCalendar // I inherited  LivewireCalendar class
{
    public function render()
    {
        return view('livewire.appointments-calendar')->layout('components.layouts.admin'); // Use layout
    }

    public function events() : Collection
    {
        return collect([
            [
                'id' => 1,
                'title' => 'Breakfast',
                'description' => 'Pancakes! 🥞',
                'date' => Carbon::today(),
            ],
            [
                'id' => 2,
                'title' => 'Meeting with Pamela',
                'description' => 'Work stuff',
                'date' => Carbon::tomorrow(),
            ],
        ]);
    }
}

I added 1 line in resources/views/livewire/appointments-calendar.blade.php file, but seems I do not need to edir this file at all ?

<div>
    resources/views/livewire/appointments-calendar.blade.php
 </div>

In layout file resources/views/components/layouts/admin.blade.php added :

@livewireScripts
@stack('scripts')
@livewire('wire-elements-modal')
@livewireCalendarScripts

</body>
</html>

<!--

@persist('scrollbar')

I use calling

    <livewire:appointments-calendar
        year="2019"
        month="12"
    />

and in browse I do not see calendar :

https://img001.prntscr.com/file/img001/QhmYtSVZRz6ydlqWL-isgQ.png

I did not find using of @livewireCalendarScripts in admin layout... What is wrong ?

sergeynilov commented 1 month ago

Searching on the branches of this plugin I found a decision in adding such render method :

class AppointmentsCalendar extends LivewireCalendar
{

    public function render()
    {
        return parent::render();
    }

It works!

sergeynilov commented 1 month ago

Thanks !