You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey this package is great but I'd love to see an implementation of a method like notifyAtInterval() that could be used to create a recurring notification until a certain condition is met. If #104 is ready for merge I could see that being a good start.
For example, consider a Project model with a completed_at and invoiced_at timestamp. When the completed_at value is is modified from null to whatever time and Project is considered "completed," the owner of the project should be notified every week to "Invoice the client!" until invoiced_at is no longer null. Some pseudo code:
// In your controller$project->completed_at = now();
// Then somewhere inside an observer or whateverpublicfunctionwasCompleted(Project$project): ScheduledNotification
{
$user = $project->owner;
// Send the reminder immediately$user->notify(newInvoiceTheClientReminder($project));
// Also send reminders every two daysreturn$user->notifyAtInterval(
newInvoiceTheClientReminder($project),
CarbonInterval::days(2),
fn(Project$project) => !is_null($project->invoiced_at) // A closure to determine when it should stop sending
);
}
Under the hood I imagine this could make use of shouldInterrupt but that may also be a very dumb idea. I'm new to the whole world of Notifications.
A backoff configuration or if someone has an invalid email and the SMTP service fails as an example, it doesn't reattempt it very minute or someway to handle cancelling a notification if an exception is thrown.
Is there anything people suggest for v3? Happy to make BC breaks if required, as long as there is a path for migration for existing users.
Strict types will be the main one.
cc @thomasjohnkane
The text was updated successfully, but these errors were encountered: