Updated scheduled tasks
This commit is contained in:
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Enums\FlightNotificationType;
|
||||
use App\Models\User;
|
||||
use App\Models\UserFlight;
|
||||
use App\Services\FollowerNotificationService;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class FlightObserver
|
||||
{
|
||||
|
||||
protected function clearCache(UserFlight $flight): void
|
||||
{
|
||||
Cache::forget("user_flights_{$flight->user->id}");
|
||||
@@ -27,6 +30,7 @@ class FlightObserver
|
||||
{
|
||||
$flight->user->calculateAchievements();
|
||||
$this->clearCache($flight);
|
||||
new FollowerNotificationService()->notifyFlightEvent($flight, FlightNotificationType::forCreation($flight));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,5 +53,9 @@ class FlightObserver
|
||||
{
|
||||
$flight->user->calculateAchievements();
|
||||
$this->clearCache($flight);
|
||||
|
||||
if ($flight->departure_date->isFuture()) {
|
||||
new FollowerNotificationService()->notifyFlightEvent($flight, FlightNotificationType::Cancelled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user