1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Mail/TemplateEmail.php
David Bomba 550cb42722
Dynamically apply locale (#3140)
* Minor fixes for OpenAPI docs for clients

* Add fields to company transformer

* Padding email templates, system level and custom

* Minor fixes for email template subject

* Working on Email Templates

* Clean up User model, remove redundant permissions methods

* Implement Locale for API

* Implement Locale middleware for client routes
2019-12-11 07:25:54 +11:00

49 lines
1.3 KiB
PHP

<?php
namespace App\Mail;
use App\Utils\Ninja;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class TemplateEmail extends Mailable
{
use Queueable, SerializesModels;
private $template; //the template to use
private $message; //the message array (subject and body)
private $user; //the user the email will be sent from
public function __construct($message, $template, $user)
{
$this->message = $message;
$this->template = $template;
$this->user = $user;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
/*Alter Run Time Mailer configuration (driver etc etc) to regenerate the Mailer Singleton*/
//if using a system level template
$template_name = 'email.template.'.$this->template;
return $this->from($this->user->email, $this->user->present()->name()) //todo this needs to be fixed to handle the hosted version
->subject($this->message['subject'])
->view($template_name, [
'body' => $this->message['body'],
'footer' => $this->message['footer'],
'title' => $this->message['title'],
]);
}
}