1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Services/Payment/SendEmail.php
David Bomba 1e35c90ee6
Fixes for Tests, MultiDB (#3334)
* refactor send_invoice to generic -> send

* Code cleanup

* Fixes for tests and multidb
2020-02-15 23:27:24 +11:00

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);
}
});
}
}