Added Email Capability

This commit is contained in:
2026-07-07 20:59:05 +10:00
parent c6065577af
commit 6d0ecb19c9
40 changed files with 1153 additions and 128 deletions
+3 -19
View File
@@ -11,25 +11,12 @@ use Illuminate\Support\Facades\Cache;
class FlightObserver
{
protected function clearCache(UserFlight $flight): void
{
Cache::forget("user_flights_{$flight->user->id}");
$flight
->user
->followers()
->get()
->each(fn ($follower) => Cache::forget("user_following_flights_{$follower->id}"));
}
/**
* Recalculate after a flight is created.
*/
public function created(UserFlight $flight): void
{
$flight->user->calculateAchievements();
$this->clearCache($flight);
$flight->user->calculateAchievementsAndClearCache();
new FollowerNotificationService()->notifyFlightEvent($flight, FlightNotificationType::forCreation($flight));
}
@@ -41,8 +28,7 @@ class FlightObserver
public function updated(UserFlight $flight): void
{
\Log::info('Observer fired for flight ' . $flight->id);
$flight->user->calculateAchievements();
$this->clearCache($flight);
$flight->user->calculateAchievementsAndClearCache();
}
/**
@@ -51,9 +37,7 @@ class FlightObserver
*/
public function deleted(UserFlight $flight): void
{
$flight->user->calculateAchievements();
$this->clearCache($flight);
$flight->user->calculateAchievementsAndClearCache();
if ($flight->departure_date->isFuture()) {
new FollowerNotificationService()->notifyFlightEvent($flight, FlightNotificationType::Cancelled);
}