2019-11-20 23:16:01 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Notifications\Channels;
|
|
|
|
|
|
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
|
|
|
|
|
|
trait MailChannel
|
|
|
|
{
|
2020-05-09 23:31:25 +08:00
|
|
|
protected $mailSubject;
|
|
|
|
protected $mailTemplate;
|
|
|
|
protected $mailTemplateArgs;
|
2019-11-20 23:16:01 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the arguments for the toMail() method
|
|
|
|
*
|
|
|
|
* @param string $subject Email subject
|
|
|
|
* @param string $template Markdown template to use
|
|
|
|
* @param array $args Arguments to pass to the template
|
|
|
|
*/
|
|
|
|
public function setMailable($subject, $template, $args)
|
|
|
|
{
|
|
|
|
$this->mailSubject = $subject;
|
|
|
|
$this->mailTemplate = $template;
|
|
|
|
$this->mailTemplateArgs = $args;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the mail representation of the notification.
|
|
|
|
*
|
|
|
|
* @param mixed $notifiable
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
|
|
|
*/
|
|
|
|
public function toMail($notifiable)
|
|
|
|
{
|
|
|
|
return (new MailMessage())
|
|
|
|
->from(config('mail.from.address', 'no-reply@phpvms.net'))
|
|
|
|
->subject($this->mailSubject)
|
|
|
|
->markdown($this->mailTemplate, $this->mailTemplateArgs);
|
|
|
|
}
|
|
|
|
}
|