user->calculateAchievementsAndClearCache(); new FollowerNotificationService()->notifyFlightEvent($flight, FlightNotificationType::forCreation($flight)); } /** * Recalculate after a flight is updated. * Cabin class, flight type, airline, etc. may have changed, * which could unlock or revoke achievements. */ public function updated(UserFlight $flight): void { \Log::info('Observer fired for flight ' . $flight->id); $flight->user->calculateAchievementsAndClearCache(); } /** * Recalculate after a flight is deleted. * Previously earned achievements may no longer be valid. */ public function deleted(UserFlight $flight): void { $flight->user->calculateAchievementsAndClearCache(); if ($flight->departure_date->isFuture()) { new FollowerNotificationService()->notifyFlightEvent($flight, FlightNotificationType::Cancelled); } } }