laravel - Laravel 网络推送通知
问题描述
我有一个用户注册系统。我想在管理员批准该用户帐户时向特定用户发送网络通知。电子邮件已经发送给用户。我尝试使用这个 pusher.data 也插入到通知表中。但总是 notifiable_id 值显示为“1”。截屏
这是通知类的代码
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class UserRegistrationCompleteNotification extends Notification
{
use Queueable;
private $details;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($details,$email)
{
$this->details= $details;
$this->email = $email;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail','database'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
$notifiable->email = $this->email;
return (new MailMessage)
->greeting($this->details['greeting'])
->subject('【M&A】 会員登録のご案内')
->line($this->details['body1'])
->line($this->details['body2'])
->line($this->details['body3'])
->line($this->details['body4'])
->line($this->details['body5'])
->line($this->details['body6'])
->line($this->details['body7'])
->line($this->details['body8'])
->line($this->details['body9'])
->line($this->details['body10'])
->line($this->details['thanks']);
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
public function toDatabase($notifiable)
{
return [
];
}
}
解决方案
推荐阅读
- javascript - user.roles.map 抛出无法读取未定义 Discord.js 的地图
- javascript - 如何在全日历中更改时隙格式
- excel - 在子过程中传递类模块的实例
- python - Django将图像保存到数据库
- sqlite - 尝试将带有破折号的 JSON 字符串从 Tcl 传递到浏览器,但无法解析?
- python - 如何使用 tf.keras.Model.summary 和 plot_model 查看子模型的层,而不是看到模型打印最终的顺序层?
- mysql - 美国的产品组在 SQL 中没有销售
- ckeditor - 使用 dropzone.js 时无法保存 CKEditor 的数据
- vim - 有时 Vim 开始忽略 Ctrl 键上的映射
- node.js - 为什么我的 digitalocean 液滴不会从我的 API 请求中返回任何内容