phpvms/app/Notifications/Channels/MailChannel.php
Nabeel S 9b2e466b7e
Discord notifications for PIREP and News events #433 (#1215)
* Discord notifications for events #433

* Style fixes

* Check for blank webhook urls and disable

* Cleanup items after review

* Changes and fixes

* Style fixes

* Don't load env for testing

* Fix status text

* Refactor saving fields/fares so events get the latest data

* Cleanup

* Style fixes
2021-06-04 10:51:59 -04:00

42 lines
1.1 KiB
PHP

<?php
namespace App\Notifications\Channels;
use Illuminate\Notifications\Messages\MailMessage;
trait MailChannel
{
protected $mailSubject;
protected $mailTemplate;
protected $mailTemplateArgs;
/**
* 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(string $subject, string $template, array $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'), config('mail.from.name'))
->subject($this->mailSubject)
->markdown($this->mailTemplate, $this->mailTemplateArgs);
}
}