spinyman / laravel-will-queue
1.0.2
2019-07-16 16:38 UTC
Requires
- php: ~5.6|~7.0
- illuminate/support: ~5.1
This package is auto-updated.
Last update: 2024-09-17 04:42:17 UTC
README
This package gives you ability to change notification type (instant or via queue) dynamically.
Install
Via Composer
$ composer require spinyman/laravel-will-queue
Usage
-
First of all you have to deimplement ShouldQueue interface from all notification models:
class EmailNotification extends Notification
implements ShouldQueue -
Make changes in User model:
use Illuminate\Notifications\Notifiable;use SpinyMan\WillQueue\Notifiable;
use SpinyMan\WillQueue\Notifiable; class User extends Authenticatable { use Notifiable; ... }
-
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());