diff --git a/README.md b/README.md index aa924fd..c21b8fa 100755 --- a/README.md +++ b/README.md @@ -35,9 +35,10 @@ You can use `make:livewire` to create a new component. For example. php artisan make:livewire AppointmentsCalendar ``` -In the `AppointmentsCalendar` class, instead of extending from the base `Component` Livewire class, -extend from `LivewireCalendar`. Also, remove the `render` method. -You'll have a class similar to this snippet. +- In the `AppointmentsCalendar` class, instead of extending from the base `Component` Livewire class, +extend from `LivewireCalendar`. +- **Remove the `render` method or you will override the parent and the calendar will not display.** +- You'll have a class similar to this snippet. ``` php class AppointmentsCalendar extends LivewireCalendar @@ -119,8 +120,6 @@ Example This will render a calendar grid. -![example](https://github.com/omnia-digital/livewire-calendar/raw/master/example.png) - By default, the component will render the current month. If you want to change the starting month, you can set the `year` and `month` props. diff --git a/src/LivewireCalendar.php b/src/LivewireCalendar.php index 672af25..1204a8d 100755 --- a/src/LivewireCalendar.php +++ b/src/LivewireCalendar.php @@ -175,8 +175,8 @@ public function monthGrid() $firstDayOfGrid = $this->gridStartsAt; $lastDayOfGrid = $this->gridEndsAt; - $numbersOfWeeks = $lastDayOfGrid->diffInWeeks($firstDayOfGrid) + 1; - $days = $lastDayOfGrid->diffInDays($firstDayOfGrid) + 1; + $numbersOfWeeks = floor(abs($lastDayOfGrid->diffInWeeks($firstDayOfGrid)) + 1); + $days = floor(abs($lastDayOfGrid->diffInDays($firstDayOfGrid)) + 1); if ($days % 7 != 0) { throw new Exception("Livewire Calendar not correctly configured. Check initial inputs.");