nhattuanbl / snooze
避免Laravel通知垃圾信息
1.0
2024-06-01 22:37 UTC
This package is auto-updated.
Last update: 2024-10-01 00:11:25 UTC
README
composer require nhattuanbl/snooze
重要:版本5.4或以下,您必须在laravel项目的config/app.php
配置文件的提供商部分手动注册您的服务提供商。
'providers' => [
// Other Service Providers
Nhattuanbl\Snooze\SnoozeServiceProvider::class,
],
'aliases' => [
// Other aliases
'Snooze' => Nhattuanbl\Snooze\Facades\Snooze::class,
],
发布配置文件
php artisan vendor:publish --provider="Nhattuanbl\Snooze\NotifySnoozeProvider" --tag="config"
发布迁移文件
php artisan vendor:publish --provider="Nhattuanbl\Snooze\NotifySnoozeProvider" --tag="migration"
php artisan migrate
php artisan schedule:work
使用方法
添加通知
Snooze::send( | |||
---|---|---|---|
$overlap | string|Model | 通知的唯一键,避免重复 | App\Models\Comment::first() |
$template | string|NotifySnoozeTemplate | 文本或NotifySnoozeTemplate模型 | "有人评论了您的帖子" |
$receiver | array | 将接收通知的用户 | App\Models\User::first() |
$channels | array | 处理通知的类 | App\Notification\BillMail::class |
$util | int | 延迟时间(分钟) | 1 |
); |
立即发送通知
\Nhattuanbl\Snooze\Facades\Snooze::sendNow($overlap, string $event, $template, $receiver, array $channels = [])
创建模板
NotifySnoozeTemplate::create([ | default | ||
---|---|---|---|
type | string | unique | |
channels | array | null | |
context | string | ||
min_snooze_daytime | int | 1 | |
max_snooze_daytime | int | 5 | |
min_snooze_nighttime | int | -1 //等到早上 | |
max_snooze_nighttime | int | 5 | |
]); |