public function formatEventsToJson(array $calendarEvents)
    {
        $array = [];

        foreach ($calendarEvents as $event) {
            $start = $this->carbon
                ->copy()
                ->setTimestamp(strtotime($event->start))
                ->toIso8601String();
            $end = $this->carbon
                ->copy()
                ->setTimestamp(strtotime($event->end))
                ->toIso8601String();
            $allDay = $event->all_day == 1;

            $data = [
                'title' => $event->title,
                'description' => $event->description,
                'start' => $start,
                'end' => $end,
                'allDay' => $allDay,
                'borderColor' => $event->border_color,
                'textColor' => $event->text_color,
                'backgroundColor' => $event->background_color,
            ];

            $array[] = $data;

            if ($event->calendarEventRepeatDates()->count() > 0) {
                foreach ($event->calendarEventRepeatDates()->get() as $repeatDate) {
                    $start = $this->carbon
                        ->copy()
                        ->setTimestamp(strtotime($repeatDate->start))
                        ->toIso8601String();
                    $end = $this->carbon
                        ->copy()
                        ->setTimestamp(strtotime($repeatDate->end))
                        ->toIso8601String();

                    $data['start'] = $start;
                    $data['end'] = $end;

                    $array[] = $data;
                }
            }
        }

        return $array;
    }