# fluent-booking/2.2.0/app/Hooks/Handlers/CleanupHandlers/CalenderEventCleaner.php

Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution, version 2.2.0. 38 lines.

- Page: https://pluginprobe.com/plugins/fluent-booking/2.2.0/code/app/Hooks/Handlers/CleanupHandlers/CalenderEventCleaner.php
- Raw: https://pluginprobe.com/plugins/fluent-booking/2.2.0/raw/app/Hooks/Handlers/CleanupHandlers/CalenderEventCleaner.php
- Modified: 2026-05-12T13:33:04+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-booking/2.2.0/code/app/Hooks/Handlers/CleanupHandlers/CalenderEventCleaner.php#L10-L20`.

```php
<?php

namespace FluentBooking\App\Hooks\Handlers\CleanupHandlers;

use FluentBooking\App\Models\Booking;
use FluentBooking\App\Models\Meta;

class CalenderEventCleaner
{
    public function register()
    {
        add_action('fluent_booking/before_delete_calendar_event', [$this, 'handleBeforeDelete'], 10, 2);
    }

    public function handleBeforeDelete($calendarEvent, $calendar)
    {
        if (empty($calendarEvent)) {
            return;
        }

        Meta::query()
            ->where('object_type', 'calendar_event')
            ->where('object_id', $calendarEvent->id)->delete();

        $bookings = Booking::query()
            ->where('event_id', $calendarEvent->id)
            ->get();

        foreach ($bookings as $booking){
            $bookingId = $booking->id;
            do_action('fluent_booking/before_delete_booking', $booking);
            $booking->delete();
            do_action('fluent_booking/after_delete_booking', $bookingId);
        }


    }
}
```
