Skip to content

Commit

Permalink
Notify user in email with Queue supported
Browse files Browse the repository at this point in the history
  • Loading branch information
summerblue committed Nov 1, 2017
1 parent 12cec9e commit 943e1ff
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/Notifications/TopicReplied.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Illuminate\Notifications\Messages\MailMessage;
use App\Models\Reply;

class TopicReplied extends Notification
class TopicReplied extends Notification implements ShouldQueue
{
use Queueable;

Expand All @@ -23,7 +23,7 @@ public function __construct(Reply $reply)
public function via($notifiable)
{
// 开启通知的频道
return ['database'];
return ['database', 'mail'];
}

public function toDatabase($notifiable)
Expand All @@ -43,4 +43,13 @@ public function toDatabase($notifiable)
'topic_title' => $topic->title,
];
}

public function toMail($notifiable)
{
$url = $this->reply->topic->link(['#reply' . $this->reply->id]);

return (new MailMessage)
->line('你的话题有新回复!')
->action('查看回复', $url);
}
}

0 comments on commit 943e1ff

Please sign in to comment.