public function onBeforeDelete()
    {
        // If a reservation is deleted remove the names from the guest list
        foreach ($this->Attendees() as $attendee) {
            /** @var Attendee $attendee */
            if ($attendee->exists()) {
                $attendee->delete();
            }
        }

        // Remove the folder
        if (($folder = Folder::get()->find('Name', $this->ReservationCode)) && $folder->exists() && $folder->isEmpty()) {
            $folder->delete();
        }

        parent::onBeforeDelete();
    }
public function onBeforeDelete()
    {
        // If a reservation is deleted remove the names from the guest list
        foreach ($this->Attendees() as $attendee) {
            /** @var Attendee $attendee */
            if ($attendee->exists()) {
                $attendee->delete();
            }
        }

        // Remove the folder
        if (($folder = Folder::get()->find('Name', $this->ReservationCode)) && $folder->exists() && $folder->isEmpty()) {
            $folder->delete();
        }

        parent::onBeforeDelete();
    }
public function onBeforeDelete ( ) { // If a reservation is deleted remove the names from the guest list foreach ( $ this -> Attendees ( ) as $ attendee ) { /** @var Attendee $attendee */ if ( $ attendee -> exists ( ) ) { $ attendee -> delete ( ) ; } } // Remove the folder if ( ( $ folder = Folder :: get ( ) -> find ( 'Name' , $ this -> ReservationCode ) ) && $ folder -> exists ( ) && $ folder -> isEmpty ( ) ) { $ folder -> delete ( ) ; } parent :: onBeforeDelete ( ) ; }
After deleting a reservation, delete the attendees and files
After deleting a reservation delete the attendees and files