find($this->eventPackageId); if (! $eventPackage) { Log::warning('Guest threshold job skipped; event package missing', [ 'event_package_id' => $this->eventPackageId, ]); return; } $tenant = $eventPackage->event?->tenant; if (! $tenant) { return; } $preferences = app(\App\Services\Packages\TenantNotificationPreferences::class); if (! $preferences->shouldNotify($tenant, 'guest_thresholds')) { return; } $emails = collect([ $tenant->contact_email, $tenant->user?->email, ])->filter(fn ($email) => is_string($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) ->unique(); if ($emails->isEmpty()) { Log::info('Guest threshold notification skipped due to missing recipients', [ 'event_package_id' => $eventPackage->id, 'threshold' => $this->threshold, ]); return; } foreach ($emails as $email) { Notification::route('mail', $email)->notify(new EventPackageGuestThresholdNotification( $eventPackage, $this->threshold, $this->limit, $this->used, )); } } }