spinyman/laravel-will-queue

1.0.2 2019-07-16 16:38 UTC

This package is auto-updated.

Last update: 2024-09-17 04:42:17 UTC


README

Latest Version on Packagist Software License Total Downloads

This package gives you ability to change notification type (instant or via queue) dynamically.

Install

Via Composer

$ composer require spinyman/laravel-will-queue

Usage

  1. First of all you have to deimplement ShouldQueue interface from all notification models:

    class EmailNotification extends Notification implements ShouldQueue

  2. Make changes in User model:

    use Illuminate\Notifications\Notifiable;

    use SpinyMan\WillQueue\Notifiable;

    use SpinyMan\WillQueue\Notifiable;
    
    class User extends Authenticatable {
    	use Notifiable;
    	...
    }
  3. somewhere use notify function with second optional bool param to indicate queue (true) or instant (false) notification (default: false):

    $user = User::find(1);
    $user->notify(new EmailNotification() [, true|false]);

    OR if you are really sure to notify using queue:

    $user = User::find(1);
    $user->notifyFromQueue(new EmailNotification());