入列队,发邮件消息通知
This commit is contained in:
parent
ed8ce10700
commit
3a24232413
|
@ -7,7 +7,7 @@ class Topic extends Model
|
||||||
protected $fillable = ['title', 'category_id', 'body', 'excerpt', 'slug'];
|
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));
|
return route('topics.show', array_merge([$this->id, $this->slug], $params));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,11 @@ namespace App\Notifications;
|
||||||
|
|
||||||
use App\Models\Reply;
|
use App\Models\Reply;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
class TopicReplied extends Notification
|
class TopicReplied extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ class TopicReplied extends Notification
|
||||||
*/
|
*/
|
||||||
public function via($notifiable)
|
public function via($notifiable)
|
||||||
{
|
{
|
||||||
return ['database'];
|
return ['database', 'mail'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,9 +43,10 @@ class TopicReplied extends Notification
|
||||||
*/
|
*/
|
||||||
public function toMail($notifiable)
|
public function toMail($notifiable)
|
||||||
{
|
{
|
||||||
|
$url = $this->replay->topic->link(['#reply' . $this->replay->id]);
|
||||||
return (new MailMessage)
|
return (new MailMessage)
|
||||||
->line('The introduction to the notification.')
|
->line('你的话题有新回复.')
|
||||||
->action('Notification Action', url('/'))
|
->action('N查看回复', $url)
|
||||||
->line('Thank you for using our application!');
|
->line('Thank you for using our application!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +54,7 @@ class TopicReplied extends Notification
|
||||||
{
|
{
|
||||||
$topic = $this->replay->topic;
|
$topic = $this->replay->topic;
|
||||||
|
|
||||||
$link = $topic->link('#reply', $this->replay->id);
|
$link = $topic->link(['#reply' . $this->replay->id]);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'reply_id' => $this->replay->id,
|
'reply_id' => $this->replay->id,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user