首页 > 解决方案 > 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 [
        ];
    }
}

标签: laravelpush-notificationpusher

解决方案


推荐阅读