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
此包为您提供了动态更改通知类型(即时或通过队列)的能力。
安装
通过 Composer
$ composer require spinyman/laravel-will-queue
使用方法
-
首先,您需要从所有通知模型中取消实现 ShouldQueue 接口
class EmailNotification extends Notification
implements ShouldQueue -
在 User 模型中做更改
use Illuminate\Notifications\Notifiable;use SpinyMan\WillQueue\Notifiable;
use SpinyMan\WillQueue\Notifiable; class User extends Authenticatable { use Notifiable; ... }
-
在某个地方使用 notify 函数,并带有第二个可选的 bool 参数来指示队列(true)或即时(false)通知(默认:false)
$user = User::find(1); $user->notify(new EmailNotification() [, true|false]);
或者,如果您确实想使用队列来通知
$user = User::find(1); $user->notifyFromQueue(new EmailNotification());