ywmelo/template-message
EasyWechat template message notification for Laravel
使用 EasyWechat 的模板消息功能发送 Laravel 消息通知。
安装
composer require ywmelo/template-message
使用
创建通知:
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Ywmelo\TemplateMessage\Message\WechatTemplateMessage;
use Ywmelo\TemplateMessage\Channels\WechatTemplateMessageChannel;
class WechatTemplateMessageNotification extends Notification
{
use Queueable;
public function __construct($formId)
{
$this->formId = $formId;
}
public function via($notifiable)
{
return [WechatTemplateMessageChannel::class];
}
public function toWechatTemplateMessage($notifiable)
{
return (new WechatTemplateMessage)
->setTemplateId('template_id')
->setPage('page')
->setFormId($this->formId)
->setData([
'keyword1' => 'keyword1',
'keyword2' => 'keyword2',
'keyword3' => 'keyword3',
'keyword4' => 'keyword4',
]);
}
}
发送
$user->notify(new WechatTemplateMessageNotification($formId));
Related Packages
benwilkins/laravel-fcm-notification
Laravel FCM (Firebase Cloud Messaging) Notification Channel
979,560
208
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v1.1 | >=7.0.0 | >=5.8.1 | MIT | |
| v1.0 | ^7.1.3 | 5.8.* | MIT |