where('triggered_at', null) ->get(); foreach ($scheduledContactReminders as $scheduledReminder) { $channel = UserNotificationChannel::findOrFail($scheduledReminder->user_notification_channel_id); $contactReminder = ContactReminder::findOrFail($scheduledReminder->contact_reminder_id); if ($channel->type == UserNotificationChannel::TYPE_EMAIL && $channel->active) { $contact = $contactReminder->contact; $contactName = NameHelper::formatContactName($channel->user, $contact); Notification::route('mail', $channel->content) ->notify((new ReminderTriggered($channel, $contactReminder->label, $contactName))->locale($channel->user->locale)); } elseif ($channel->type === UserNotificationChannel::TYPE_TELEGRAM) { Notification::route('telegram', $channel->content) ->notify((new ReminderTriggered($channel, $contactReminder->label, ''))->locale($channel->user->locale)); } try { (new RescheduleContactReminderForChannel)->execute([ 'contact_reminder_id' => $scheduledReminder->contact_reminder_id, 'user_notification_channel_id' => $scheduledReminder->user_notification_channel_id, 'contact_reminder_scheduled_id' => $scheduledReminder->id, ]); } catch (ModelNotFoundException) { continue; } } } }