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

46 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
*
2022-04-27 05:20:41 +02:00
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
2020-07-01 03:06:40 +02:00
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
2020-07-01 03:06:40 +02:00
*/
namespace App\Services\Payment;
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()
{
2021-10-08 07:23:00 +02:00
$this->payment->load('company', 'client.contacts');
2020-11-09 03:39:42 +01:00
$this->payment->client->contacts->each(function ($contact) {
2021-10-05 06:20:44 +02:00
if ($contact->email) {
2020-11-09 03:39:42 +01:00
EmailPayment::dispatchNow($this->payment, $this->payment->company, $contact);
return false;
//11-01-2021 only send payment receipt to the first contact
}
});
}
}