1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-06 03:02:34 +01:00
invoiceninja/app/Services/Payment/SendEmail.php
David Bomba d9d2e21f93
Subscriptions (#3682)
* Working on subscriptions

* Implement return type in models

* Subscription implementation

* Improvements to handling importation of large accountS

* Loggin imports

* Activate collector

* Improve memory usage of import script

* Quote actions

* Send Quotes

* Fixes for seg faults!

* Minor fixes

* Fixes for client contact scopes
2020-05-09 08:35:49 +10:00

37 lines
836 B
PHP

<?php
namespace App\Services\Payment;
use App\Helpers\Email\PaymentEmail;
use App\Jobs\Payment\EmailPayment;
class SendEmail
{
public $payment;
public $contact;
public function __construct($payment, $contact)
{
$this->payment = $payment;
$this->contact = $contact;
}
/**
* Builds the correct template to send
* @param string $reminder_template The template name ie reminder1
* @return array
*/
public function run()
{
$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);
}
});
}
}