2020-02-15 10:01:15 +01:00
|
|
|
<?php
|
2020-07-01 03:06:40 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2020-07-01 03:06:40 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2021-01-03 22:54:54 +01:00
|
|
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
2020-07-01 03:06:40 +02:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
2020-02-15 10:01:15 +01:00
|
|
|
namespace App\Services\Payment;
|
|
|
|
|
|
|
|
use App\Jobs\Payment\EmailPayment;
|
|
|
|
|
|
|
|
class SendEmail
|
|
|
|
{
|
|
|
|
public $payment;
|
|
|
|
|
2020-05-09 00:35:49 +02:00
|
|
|
public $contact;
|
|
|
|
|
|
|
|
public function __construct($payment, $contact)
|
2020-02-15 10:01:15 +01:00
|
|
|
{
|
|
|
|
$this->payment = $payment;
|
2020-05-09 00:35:49 +02:00
|
|
|
|
|
|
|
$this->contact = $contact;
|
2020-02-15 10:01:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Builds the correct template to send.
|
2020-10-28 11:10:49 +01:00
|
|
|
* @return void
|
2020-02-15 10:01:15 +01:00
|
|
|
*/
|
2020-05-09 00:35:49 +02:00
|
|
|
public function run()
|
2020-02-15 10:01:15 +01:00
|
|
|
{
|
2020-11-09 03:39:42 +01:00
|
|
|
$this->payment->client->contacts->each(function ($contact) {
|
|
|
|
if ($contact->send_email && $contact->email) {
|
|
|
|
EmailPayment::dispatchNow($this->payment, $this->payment->company, $contact);
|
2020-02-15 10:01:15 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|