1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 08:51:34 +02:00
invoiceninja/app/Services/Payment/SendEmail.php

45 lines
1.0 KiB
PHP
Raw Normal View History

<?php
2020-07-01 03:06:40 +02:00
/**
* Invoice Ninja (https://invoiceninja.com).
2020-07-01 03:06:40 +02:00
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
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.
2020-10-28 11:10:49 +01:00
* @return void
*/
public function run()
{
$email_builder = (new PaymentEmail())->build($this->payment, $this->contact);
$this->payment->client->contacts->each(function ($contact) use ($email_builder) {
if ($contact->send && $contact->email) {
2020-11-01 04:19:03 +01:00
EmailPayment::dispatchNow($this->payment, $email_builder, $contact, $this->payment->company);
}
});
}
}