{"id":14974670,"url":"https://github.com/thomasjohnkane/snooze","last_synced_at":"2025-04-29T14:14:36.362Z","repository":{"id":34247437,"uuid":"173246329","full_name":"thomasjohnkane/snooze","owner":"thomasjohnkane","description":"A package to simplify automating future notifications and reminders in Laravel","archived":false,"fork":false,"pushed_at":"2025-04-22T00:53:26.000Z","size":215,"stargazers_count":891,"open_issues_count":14,"forks_count":98,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-29T14:14:28.938Z","etag":null,"topics":["boarding-email-drips","delayed-notifications","delayed-queue","drip-campaigns","email-marketing","laravel","laravel-framework","laravel-package","notifications","onboarding-emails","reminder","reminder-emails","reminders","scheduled-notifications","snooze"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thomasjohnkane.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-01T06:19:18.000Z","updated_at":"2025-04-23T23:30:39.000Z","dependencies_parsed_at":"2023-02-18T12:16:13.903Z","dependency_job_id":"165f41bd-7e01-48b0-9d5b-64a45435db12","html_url":"https://github.com/thomasjohnkane/snooze","commit_stats":{"total_commits":94,"total_committers":17,"mean_commits":5.529411764705882,"dds":0.5531914893617021,"last_synced_commit":"bf0d701df0ac8c4d215797548b876e9efba46b75"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasjohnkane%2Fsnooze","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasjohnkane%2Fsnooze/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasjohnkane%2Fsnooze/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasjohnkane%2Fsnooze/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomasjohnkane","download_url":"https://codeload.github.com/thomasjohnkane/snooze/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251516949,"owners_count":21601911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boarding-email-drips","delayed-notifications","delayed-queue","drip-campaigns","email-marketing","laravel","laravel-framework","laravel-package","notifications","onboarding-emails","reminder","reminder-emails","reminders","scheduled-notifications","snooze"],"created_at":"2024-09-24T13:50:54.071Z","updated_at":"2025-04-29T14:14:36.333Z","avatar_url":"https://github.com/thomasjohnkane.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Laravel Snooze\n=================================\n\n\u003e Schedule future notifications and reminders in Laravel\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"./snooze-logo-v1.png\" /\u003e\n\u003c/p\u003e\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/thomasjohnkane/snooze/php.yml?branch=master\n)](https://github.com/thomasjohnkane/snooze/actions)\n[![styleci](https://styleci.io/repos/173246329/shield)](https://styleci.io/repos/173246329)\n\n[![Latest Stable Version](https://poser.pugx.org/thomasjohnkane/snooze/v/stable)](https://packagist.org/packages/thomasjohnkane/snooze)\n[![Total Downloads](https://poser.pugx.org/thomasjohnkane/snooze/downloads)](https://packagist.org/packages/thomasjohnkane/snooze)\n[![License](https://poser.pugx.org/thomasjohnkane/snooze/license)](https://packagist.org/packages/thomasjohnkane/snooze)\n\n### Why use this package?\n- Ever wanted to schedule a \u003cb\u003efuture\u003c/b\u003e notification to go out at a specific time? (was the delayed queue option not enough?)\n- Want a simple on-boarding email drip?\n- How about happy birthday emails?\n\n#### Common use cases\n- Reminder system (1 week before appt, 1 day before, 1 hour before, etc)\n- Follow-up surveys (2 days after purchase)\n- On-boarding Email Drips (Welcome email after sign-up, additional tips after 3 days, upsell offer after 7 days)\n- Short-Term Recurring reports (send every week for the next 4 weeks)\n\n## Installation\n\nInstall via composer\n```bash\ncomposer require thomasjohnkane/snooze\n```\n```bash\nphp artisan migrate\n```\n\n### Publish Configuration File\n\n```bash\nphp artisan vendor:publish --provider=\"Thomasjohnkane\\Snooze\\ServiceProvider\" --tag=\"config\"\n```\n\n## Usage\n\n#### Using the model trait\nSnooze provides a trait for your model, similar to the standard `Notifiable` trait.\nIt adds a `notifyAt()` method to your model to schedule notifications.\n\n```php\nuse Thomasjohnkane\\Snooze\\Traits\\SnoozeNotifiable;\nuse Illuminate\\Notifications\\Notifiable;\n\nclass User extends Model {\n    use Notifiable, SnoozeNotifiable;\n\n    // ...\n}\n\n// Schedule a birthday notification\n$user-\u003enotifyAt(new BirthdayNotification, Carbon::parse($user-\u003ebirthday));\n\n// Schedule for a week from now\n$user-\u003enotifyAt(new NextWeekNotification, Carbon::now()-\u003eaddDays(7));\n\n// Schedule for new years eve\n$user-\u003enotifyAt(new NewYearNotification, Carbon::parse('last day of this year'));\n```\n\n#### Using the ScheduledNotification::create helper\nYou can also use the `create` method on the `ScheduledNotification`.\n```php\nScheduledNotification::create(\n     Auth::user(), // Target\n     new ScheduledNotificationExample($order), // Notification\n     Carbon::now()-\u003eaddHour() // Send At\n);\n```\n\nThis is also useful for scheduling anonymous notifications (routed direct, rather than on a model).\n```php\n$target = (new AnonymousNotifiable)\n    -\u003eroute('mail', 'hello@example.com')\n    -\u003eroute('sms', '56546456566');\n\nScheduledNotification::create(\n     $target, // Target\n     new ScheduledNotificationExample($order), // Notification\n     Carbon::now()-\u003eaddDay() // Send At\n);\n```\n\n#### An important note about scheduling the `snooze:send` command\n\nCreating a scheduled notification will add the notification to the database. It will be sent by running `snooze:send` command at (or after) the stored `sendAt` time.\n\nThe `snooze:send` command is scheduled to run every minute by default. You can change this value (`sendFrequency`) in the published config file. Available options are `everyMinute`, `everyFiveMinutes`, `everyTenMinutes`, `everyFifteenMinutes`, `everyThirtyMinutes`, `hourly`, and `daily`.\n\nThe only thing you need to do is make sure `schedule:run` is also running. You can test this by running `php artisan schedule:run` in the console. [To make it run automatically, read here][6].\n\n\u003eNote: If you would prefer snooze to not automatically schedule the commands, you can set the `scheduleCommands` config value to `false`\n\n### Setting the send tolerance\n\nIf your scheduler stops working, a backlog of scheduled notifications will build up. To prevent users receiving all of\nthe old scheduled notifications at once, the command will only send mail within the configured tolerance.\nBy default this is set to 24 hours, so only mail scheduled to be sent within that window will be sent. This can be\nconfigured (in seconds) using the `SCHEDULED_NOTIFICATION_SEND_TOLERANCE` environment variable or in the `snooze.php` config file.\n\n### Setting the prune age\n\nThe package can prune sent and cancelled messages that were sent/cancelled more than x days ago. You can\nconfigure this using the `SCHEDULED_NOTIFICATION_PRUNE_AGE` environment variable or in the `snooze.php` config file\n(unit is days). This feature is turned off by default.\n\n#### Detailed Examples\n\n- [Delayed Notification (1 week)][3]\n- [Simple On-boarding Email Drip][5]\n- [Exposing Custom Data to the Notification/Email][4]\n\n**Cancelling Scheduled Notifications**\n\n```php\n$notification-\u003ecancel();\n```\n\u003csmall\u003e\u003cb\u003eNote:\u003c/b\u003e you cannot cancel a notification that has already been sent.\u003c/small\u003e\n\n**Rescheduling Scheduled Notifications**\n\n```php\n$rescheduleAt = Carbon::now()-\u003eaddDay(1)\n\n$notification-\u003ereschedule($rescheduleAt)\n```\n\u003csmall\u003e\u003cb\u003eNote:\u003c/b\u003e you cannot reschedule a notification that has already been sent or cancelled.\u003c/small\u003e\n\u003csmall\u003eIf you want to duplicate a notification that has already been sent or cancelled, pass a truthy second parameter along with the new send date; `reschedule($date, true)`, or use the `scheduleAgainAt($date)` method shown below.\u003c/small\u003e\n\n**Duplicate a Scheduled Notification to be sent again**\n\n```php\n$notification-\u003escheduleAgainAt($newDate); // Returns the new (duplicated) $notification\n```\n\n**Check a scheduled notification's status**\n```php\n// Check if a notification is already cancelled\n\n$result = $notification-\u003eisCancelled(); // returns a bool\n\n// Check if a notification is already sent\n\n$result = $notification-\u003eisSent(); // returns a bool\n```\n\n**Conditionally interrupt a scheduled notification**\n\nIf you'd like to stop an email from being sent conditionally, you can add the `shouldInterrupt()` method to any notification. This method will be checked immediately before the notification is sent.\n\nFor example, you might not send a future drip notification if a user has become inactive, or the order the notification was for has been canceled.\n\n```php\npublic function shouldInterrupt($notifiable) {\n    return $notifiable-\u003eisInactive() || $this-\u003eorder-\u003eisCanceled();\n}\n```\n\nIf this method is not present on your notification, the notification will *not* be interrupted. Consider creating a shouldInterupt trait if you'd like to repeat conditional logic on groups of notifications.\n\n**Scheduled Notification Meta Information**\n\nIt's possible to store meta information on a scheduled notification, and then query the scheduled notifications by this meta information at a later stage.\n\nThis functionality could be useful for when you store notifications for a future date, but some change in the system requires\nyou to update them. By using the meta column, it's possible to more easily query these scheduled notifications from the database by something else than\nthe notifiable.\n\n***Storing Meta Information***\n\nUsing the `ScheduledNotification::create` helper\n\n```php\nScheduledNotification::create(\n     $target, // Target\n     new ScheduledNotificationExample($order), // Notification\n     Carbon::now()-\u003eaddDay(), // Send At,\n     ['foo' =\u003e 'bar'] // Meta Information\n);\n```\n\nUsing the `notifyAt` trait\n\n```php\n  $user-\u003enotifyAt(new BirthdayNotification, Carbon::parse($user-\u003ebirthday), ['foo' =\u003e 'bar']);\n```\n\n***Retrieving Meta Information from Scheduled Notifications***\n\nYou can call the `getMeta` function on an existing scheduled notification to retrieve the meta information for the specific notification.\n\nPassing no parameters to this function will return the entire meta column in array form.\n\nPassing a string key (`getMeta('foo')`), will retrieve the specific key from the meta column.\n\n***Querying Scheduled Notifications using the ScheduledNotification::findByMeta helper***\n\nIt's possible to query the database for scheduled notifications with certain meta information, by using the `findByMeta` helper.\n\n```php\n  ScheduledNotification::findByMeta('foo', 'bar'); //key and value\n```\n\nThe first parameter is the meta key, and the second parameter is the value to look for.\n\n\u003eNote: The index column doesn't currently make use of a database index\n\n**Conditionally turn off scheduler**\n\nIf you would like to disable sending of scheduled notifications, set an env variable of `SCHEDULED_NOTIFICATIONS_DISABLED` to `true`. You will still be able to schedule notifications, and they will be sent once the scheduler is enabled.\n\nThis could be useful for ensuring that scheduled notifications are only sent by a specific server, for example.\n\n**Enable onOneServer**\n\nIf you would like the `snooze` commands to utilise the Laravel Scheduler's `onOneServer` functionality, you can use the following environment variable:\n\n```bash\n\nSCHEDULED_NOTIFICATIONS_ONE_SERVER = true\n\n```\n\n## Running the Tests\n\n```bash\ncomposer test\n```\n\n## Security\n\nIf you discover any security related issues, please email instead of using the issue tracker.\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/thomasjohnkane/snooze/fork\u003e)\n2. Create your feature branch (`git checkout -b feature/fooBar`)\n3. Commit your changes (`git commit -am 'Add some fooBar'`)\n4. Push to the branch (`git push origin feature/fooBar`)\n5. Create a new Pull Request\n\n## Credits\n\n- [Thomas Kane \u0026\u0026 Flux Bucket](https://github.com/thomasjohnkane)\n- [Atymic](https://github.com/atymic)\n- [All contributors](https://github.com/thomasjohnkane/snooze/graphs/contributors)\n\nThis package is bootstrapped with the help of\n[melihovv/laravel-package-generator](https://github.com/melihovv/laravel-package-generator).\n\n[1]: ./docs/register-provider-and-facade.md \"Register Service Provider \u0026\u0026 Facade\"\n[2]: https://carbon.nesbot.com/docs/ \"Carbon\"\n[3]: ./docs/examples/basic-delayed-notification.md \"Delayed 1 Week Example\"\n[4]: ./docs/examples/custom-data-example.md \"Custom Data Example\"\n[5]: ./docs/examples/on-boarding-email-drip.md  \"On-boarding Drip Example\"\n[6]: https://laravel.com/docs/5.7/scheduling#introduction \"Configure Laravel Scheduler\"\n[7]: https://laravel.com/docs/5.7/scheduling#introduction \"Generators\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasjohnkane%2Fsnooze","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomasjohnkane%2Fsnooze","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasjohnkane%2Fsnooze/lists"}