入列队,发邮件消息通知

This commit is contained in:
fthvgb1 2018-01-30 01:17:57 +08:00
parent ed8ce10700
commit 3a24232413
2 changed files with 8 additions and 6 deletions

View File

@ -7,7 +7,7 @@ class Topic extends Model
protected $fillable = ['title', 'category_id', 'body', 'excerpt', 'slug'];
public function link(...$params)
public function link($params)
{
return route('topics.show', array_merge([$this->id, $this->slug], $params));
}

View File

@ -4,10 +4,11 @@ namespace App\Notifications;
use App\Models\Reply;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class TopicReplied extends Notification
class TopicReplied extends Notification implements ShouldQueue
{
use Queueable;
@ -31,7 +32,7 @@ class TopicReplied extends Notification
*/
public function via($notifiable)
{
return ['database'];
return ['database', 'mail'];
}
/**
@ -42,9 +43,10 @@ class TopicReplied extends Notification
*/
public function toMail($notifiable)
{
$url = $this->replay->topic->link(['#reply' . $this->replay->id]);
return (new MailMessage)
->line('The introduction to the notification.')
->action('Notification Action', url('/'))
->line('你的话题有新回复.')
->action('N查看回复', $url)
->line('Thank you for using our application!');
}
@ -52,7 +54,7 @@ class TopicReplied extends Notification
{
$topic = $this->replay->topic;
$link = $topic->link('#reply', $this->replay->id);
$link = $topic->link(['#reply' . $this->replay->id]);
return [
'reply_id' => $this->replay->id,