Laravel Livewire Calendar Component

Packages

November 24th, 2021

calender-schedule.png

Laravel Livewire Calendar is a component by Andrés Santibáñez to show events in a good looking monthly calendar.

Livewire Calendar UI preview

To get started with this component, you'll create a component that extends the LivewireCalendar class and override the events() method:

1public function events(): Collection
2{
3 return Model::query()
4 ->whereDate('scheduled_at', '>=', $this->gridStartsAt)
5 ->whereDate('scheduled_at', '<=', $this->gridEndsAt)
6 ->get()
7 ->map(function (Model $model) {
8 return [
9 'id' => $model->id,
10 'title' => $model->title,
11 'description' => $model->notes,
12 'date' => $model->scheduled_at,
13 ];
14 });
15}

Next, you need to include your component in any view as you would any Livewire component:

1<livewire:appointments-calendar/>
2 
3{{-- Specify year and month --}}
4<livewire:appointments-calendar
5 year="2019"
6 month="12"
7/>

This component also provides more advanced UI customization. Check out the readme for advanced customization. You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.