All Projects → thomasjohnkane → Snooze

thomasjohnkane / Snooze

Licence: mit
A package to simplify automating future notifications and reminders in Laravel

Projects that are alternatives of or similar to Snooze

Backup
MySQL Database backup package for Laravel
Stars: ✭ 66 (-87.18%)
Mutual labels:  laravel, laravel-package, laravel-framework
Dropzone Laravel Image Upload
Laravel 5.2 and Dropzone.js auto image uploads with removal links
Stars: ✭ 92 (-82.14%)
Mutual labels:  laravel, laravel-package, laravel-framework
Laraupdater
Enable Laravel App Self-Update. Allow your Laravel Application to auto-update itself.
Stars: ✭ 75 (-85.44%)
Mutual labels:  laravel, laravel-package, laravel-framework
Laravel Notify
Flexible Flash notifications for Laravel
Stars: ✭ 787 (+52.82%)
Mutual labels:  laravel, laravel-package, notifications
Auth Tests
Always-current tests for Laravel's authentication system. Curated by the community.
Stars: ✭ 230 (-55.34%)
Mutual labels:  laravel, laravel-package, laravel-framework
Laravel Compass
A REST client inside your Laravel app
Stars: ✭ 1,002 (+94.56%)
Mutual labels:  laravel, laravel-package, laravel-framework
Laravel Console Logger
Logging and Notifications for Laravel Console Commands.
Stars: ✭ 79 (-84.66%)
Mutual labels:  laravel, laravel-package, notifications
Laravel Qrcode Ecommerce
This is a complete laravel project that handles qrcodes, payments, api/microservices, and ecommerce
Stars: ✭ 36 (-93.01%)
Mutual labels:  laravel, laravel-package, laravel-framework
Wagonwheel
Offer an online version of your Laravel emails to users.
Stars: ✭ 224 (-56.5%)
Mutual labels:  laravel, laravel-package, laravel-framework
Blogetc
Easily add a full Laravel blog (with built in admin panel and public views) to your laravel project with this simple package.
Stars: ✭ 198 (-61.55%)
Mutual labels:  laravel, laravel-package, laravel-framework
Laravel Open Source Projects
A Web Artisan list of categorized OPEN SOURCE PROJECTS built with Laravel PHP Framework.
Stars: ✭ 676 (+31.26%)
Mutual labels:  laravel, laravel-package, laravel-framework
Laravel User Activity
Monitor user activity easily!
Stars: ✭ 253 (-50.87%)
Mutual labels:  laravel, laravel-package, laravel-framework
Laravel Schedulable
Schedule and unschedule eloquent models elegantly without cron jobs
Stars: ✭ 78 (-84.85%)
Mutual labels:  laravel, laravel-package, laravel-framework
Admin One Laravel Dashboard
Admin One — Free Laravel Dashboard (Bulma Buefy Vue.js SPA)
Stars: ✭ 94 (-81.75%)
Mutual labels:  laravel, laravel-package, laravel-framework
Laravel Gitscrum
GitScrum is a Project Management Tool, developed to help entrepreneurs, freelancers, managers, and teams Skyrocket their Productivity with the Agile methodology and Gamification.
Stars: ✭ 2,686 (+421.55%)
Mutual labels:  laravel, laravel-package, laravel-framework
Laravel Form Components
A set of Blade components to rapidly build forms with Tailwind CSS (v1.0 and v2.0) and Bootstrap 4. Supports validation, model binding, default values, translations, Laravel Livewire, includes default vendor styling and fully customizable!
Stars: ✭ 295 (-42.72%)
Mutual labels:  laravel, laravel-package, laravel-framework
Coreui Free Laravel Admin Template
CoreUI Free Laravel Bootstrap Admin Template
Stars: ✭ 353 (-31.46%)
Mutual labels:  laravel, laravel-framework
Bagisto
An easy to use, free and open source laravel eCommerce platform to build your online shop in no time.
Stars: ✭ 4,140 (+703.88%)
Mutual labels:  laravel, laravel-package
Laravel Onesignal
OneSignal Push Notifications for Laravel
Stars: ✭ 369 (-28.35%)
Mutual labels:  laravel, notifications
Secure Headers
PHP Secure Headers
Stars: ✭ 379 (-26.41%)
Mutual labels:  laravel, laravel-package

Laravel Snooze

Schedule future notifications and reminders in Laravel

Build Status styleci

Latest Stable Version Total Downloads License

Why use this package?

  • Ever wanted to schedule a future notification to go out at a specific time? (was the delayed queue option not enough?)
  • Want a simple on-boarding email drip?
  • How about happy birthday emails?

Common use cases

  • Reminder system (1 week before appt, 1 day before, 1 hour before, etc)
  • Follow-up surveys (2 days after purchase)
  • On-boarding Email Drips (Welcome email after sign-up, additional tips after 3 days, upsell offer after 7 days)
  • Short-Term Recurring reports (send every week for the next 4 weeks)

Installation

Install via composer

composer require thomasjohnkane/snooze
php artisan migrate

Publish Configuration File

php artisan vendor:publish --provider="Thomasjohnkane\Snooze\ServiceProvider" --tag="config"

Usage

Using the model trait

Snooze provides a trait for your model, similar to the standard Notifiable trait. It adds a notifyAt() method to your model to schedule notifications.

use Thomasjohnkane\Snooze\Traits\SnoozeNotifiable;

class User extends Model {
    use SnoozeNotifiable;

    // ...
}

// Schedule a birthday notification
$user->notifyAt(new BirthdayNotification, Carbon::parse($user->birthday));

// Schedule for a week from now
$user->notifyAt(new NextWeekNotification, Carbon::now()->addDays(7));

// Schedule for new years eve
$user->notifyAt(new NewYearNotification, Carbon::parse('last day of this year'));

Using the ScheduledNotification::create helper

You can also use the create method on the ScheduledNotification.

ScheduledNotification::create(
     Auth::user(), // Target
     new ScheduledNotificationExample($order), // Notification
     Carbon::now()->addHour() // Send At
);

This is also useful for scheduling anonymous notifications (routed direct, rather than on a model).

$target = (new AnonymousNotifiable)
    ->route('mail', '[email protected]')
    ->route('sms', '56546456566');

ScheduledNotification::create(
     $target, // Target
     new ScheduledNotificationExample($order), // Notification
     Carbon::now()->addDay() // Send At
);

An important note about scheduling the snooze:send command

Creating 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.

The 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.

The 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.

Setting the send tolerance

If your scheduler stops working, a backlog of scheduled notifications will build up. To prevent users receiving all of the old scheduled notifications at once, the command will only send mail within the configured tolerance. By default this is set to 24 hours, so only mail scheduled to be sent within that window will be sent. This can be configured (in seconds) using the SCHEDULED_NOTIFICATION_SEND_TOLERANCE environment variable or in the snooze.php config file.

Setting the prune age

The package can prune sent and cancelled messages that were sent/cancelled more than x days ago. You can configure this using the SCHEDULED_NOTIFICATION_PRUNE_AGE environment variable or in the snooze.php config file (unit is days). This feature is turned off by default.

Detailed Examples

Cancelling Scheduled Notifications

$notification->cancel();

Note: you cannot cancel a notification that has already been sent.

Rescheduling Scheduled Notifications

$rescheduleAt = Carbon::now()->addDay(1)

$notification->reschedule($rescheduleAt)

Note: you cannot reschedule a notification that has already been sent or cancelled. If 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.

Duplicate a Scheduled Notification to be sent again

$notification->scheduleAgainAt($newDate); // Returns the new (duplicated) $notification

Check a scheduled notification's status

// Check if a notification is already cancelled

$result = $notification->isCancelled(); // returns a bool

// Check if a notification is already sent

$result = $notification->isSent(); // returns a bool

Conditionally interrupt a scheduled notification

If 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.

For 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.

public function shouldInterrupt($notifiable) {
    return $notifiable->isInactive() || $this->order->isCanceled();
}

If 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.

Running the Tests

composer test

Security

If you discover any security related issues, please email instead of using the issue tracker.

Contributing

  1. Fork it (https://github.com/thomasjohnkane/snooze/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Credits

This package is bootstrapped with the help of melihovv/laravel-package-generator.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].