reply = $reply; } /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { // 开启通知的频道 // return ['database', 'mail']; return ['database']; } public function toDatabase($notifiable) { $article = $this->reply->article; $link = $article->link(); // 存入数据库里的数据 return [ 'reply_id' => $this->reply->id, 'reply_content' => $this->reply->content, 'user_id' => $this->reply->user->id, 'user_name' => $this->reply->user->name, 'article_link' => $link, 'article_id' => $article->id, 'article_title' => $article->title, ]; } /** * Get the mail representation of the notification. * * @param mixed $notifiable * @return \Illuminate\Notifications\Messages\MailMessage */ public function toMail($notifiable) { $url = $this->reply->article->link(['#reply' . $this->reply->id]); return (new MailMessage) ->line('你的文章有新回复!') ->action('查看回复', $url); } /** * Get the array representation of the notification. * * @param mixed $notifiable * @return array */ public function toArray($notifiable) { return [ // ]; } }