mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
1e35c90ee6
* refactor send_invoice to generic -> send * Code cleanup * Fixes for tests and multidb
33 lines
790 B
PHP
33 lines
790 B
PHP
<?php
|
|
|
|
namespace App\Services\Payment;
|
|
|
|
use App\Helpers\Email\PaymentEmail;
|
|
use App\Jobs\Payment\EmailPayment;
|
|
|
|
class SendEmail
|
|
{
|
|
public $payment;
|
|
|
|
public function __construct($payment)
|
|
{
|
|
$this->payment = $payment;
|
|
}
|
|
|
|
/**
|
|
* Builds the correct template to send
|
|
* @param string $reminder_template The template name ie reminder1
|
|
* @return array
|
|
*/
|
|
public function run($contact = null): array
|
|
{
|
|
$email_builder = (new PaymentEmail())->build($this->payment, $contact);
|
|
|
|
$this->payment->client->contacts->each(function ($contact) use ($email_builder) {
|
|
if ($contact->send && $contact->email) {
|
|
EmailPayment::dispatchNow($this->payment, $email_builder, $contact);
|
|
}
|
|
});
|
|
}
|
|
}
|