2020-02-15 10:01:15 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Created by PhpStorm.
|
|
|
|
* User: michael.hampton
|
|
|
|
* Date: 14/02/2020
|
|
|
|
* Time: 19:51
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Helpers\Email;
|
|
|
|
|
|
|
|
use App\Models\Payment;
|
|
|
|
|
2020-04-06 14:32:27 +02:00
|
|
|
class PaymentEmail extends EmailBuilder
|
2020-02-15 10:01:15 +01:00
|
|
|
{
|
2020-03-21 06:37:30 +01:00
|
|
|
public function build(Payment $payment, $contact = null)
|
|
|
|
{
|
2020-02-15 10:01:15 +01:00
|
|
|
$client = $payment->client;
|
|
|
|
|
|
|
|
$body_template = $client->getSetting('email_template_payment');
|
|
|
|
|
|
|
|
/* Use default translations if a custom message has not been set*/
|
|
|
|
if (iconv_strlen($body_template) == 0) {
|
2020-03-21 06:37:30 +01:00
|
|
|
$body_template = trans(
|
|
|
|
'texts.payment_message',
|
|
|
|
['amount' => $payment->amount, 'company' => $payment->company->present()->name()],
|
|
|
|
null,
|
|
|
|
$this->client->locale()
|
|
|
|
);
|
2020-02-15 10:01:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$subject_template = $client->getSetting('email_subject_payment');
|
|
|
|
|
|
|
|
if (iconv_strlen($subject_template) == 0) {
|
2020-03-21 06:37:30 +01:00
|
|
|
$subject_template = trans(
|
|
|
|
'texts.payment_subject',
|
|
|
|
['number' => $payment->number, 'company' => $payment->company->present()->name()],
|
|
|
|
null,
|
|
|
|
$payment->client->locale()
|
|
|
|
);
|
2020-02-15 10:01:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->setTemplate($payment->client->getSetting('email_style'))
|
|
|
|
->setSubject($subject_template)
|
|
|
|
->setBody($body_template);
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|