get(); foreach ($staleFeeds as $feed) { $alreadyNotified = Notification::query() ->where('type', NotificationTypeEnum::FEED_STALE) ->where('notifiable_type', $feed->getMorphClass()) ->where('notifiable_id', $feed->getKey()) ->unread() ->exists(); if ($alreadyNotified) { continue; } $notificationService->send( type: NotificationTypeEnum::FEED_STALE, severity: NotificationSeverityEnum::WARNING, title: "Feed \"{$feed->name}\" is stale", message: $feed->last_fetched_at ? "Last fetched {$feed->last_fetched_at->diffForHumans()}. Threshold is {$thresholdHours} hours." : "This feed has never been fetched. Threshold is {$thresholdHours} hours.", notifiable: $feed, ); } } }