fixed email notification

This commit is contained in:
denisdulici 2020-01-09 14:55:57 +03:00
parent 481f19305b
commit 41b6489c0a

View File

@ -2,6 +2,7 @@
namespace App\Abstracts;
use App\Models\Common\EmailTemplate;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification as BaseNotification;
@ -34,26 +35,24 @@ abstract class Notification extends BaseNotification
*/
public function initMessage()
{
$template = EmailTemplate::alias($this->template)->first();
$message = (new MailMessage)
->from(config('mail.from.address'), config('mail.from.name'))
->subject($this->getSubject())
->view('partials.email.body', ['body' => $this->getBody()]);
->subject($this->getSubject($template))
->view('partials.email.body', ['body' => $this->getBody($template)]);
return $message;
}
public function getSubject()
public function getSubject($template)
{
$content = setting('email.' . $this->template . '_subject');
return $this->replaceTags($content);
return $this->replaceTags($template->subject);
}
public function getBody()
public function getBody($template)
{
$content = setting('email.' . $this->template . '_body');
return $this->replaceTags($content);
return $this->replaceTags($template->body);
}
public function replaceTags($content)