getAvailable(false) as $event) { if ($event->registration_final_end < $now ) { $event->registration_allowed = false; $event->save(); } } } }