Added Email Capability
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user