Notifications
Intro
Notifications are sent to users via different channels to engage with, update and communicate with the users of the application. This app has a notifications engine which is used to handle the prescription and delivery of these notifications.
Admin notifications
The AdminNotifications model serves the purpose of allowing admins to create manual notifications which they can draft and then send (or schedule) to a selected audience of users.
Admin notification CRUD is handled in the Filament dashboard via the AdminNotificationResource class and structure.
Immediate sending of the admin notifications
Once an Admin notification is set to active and saved, the AdminNotificationObserver checks to see if it was scheduled or not. If not scheduled, the SendAdminNotificationJob is dispatched and the notification is sent immediately.
Scheduled sending of the admin notifications
Any scheduled admin notifications are sent via the SendScheduledNotifications action which is fired using the SendScheduledNotifications class which is fired every 10 minutes in the Kernal scheduler.
The action checks for any active, unsent, undispatched admin notifications that are overdue in the scheduler. The action only considers notifications scheduled for the past day to reduce risk of erroneously sending lots of notifications in the future.
Email notifications
Email notifications are all send using the SendEmailJob which sets up the merge_vars and accesses the MandrillService to send the email.
In-app notifications
In-app notifications are sent using the native Laravel notify() method using the class StandardInApp notification instance. These notifications are stored in the notifications DB table which are then shown to users can can be marked as read etc. using the native Laravel notifications functionality.