2020-02-15 09:01:15 +00:00
|
|
|
<?php
|
2020-07-01 11:06:40 +10:00
|
|
|
/**
|
2020-09-06 19:38:10 +10:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2020-07-01 11:06:40 +10:00
|
|
|
*
|
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
|
*
|
2022-04-27 13:20:41 +10:00
|
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
2020-07-01 11:06:40 +10:00
|
|
|
*
|
2021-06-16 16:58:16 +10:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2020-07-01 11:06:40 +10:00
|
|
|
*/
|
|
|
|
|
|
2020-02-15 09:01:15 +00:00
|
|
|
namespace App\Services\Payment;
|
|
|
|
|
|
|
|
|
|
use App\Jobs\Payment\EmailPayment;
|
|
|
|
|
|
|
|
|
|
class SendEmail
|
|
|
|
|
{
|
|
|
|
|
public $payment;
|
|
|
|
|
|
2020-05-09 08:35:49 +10:00
|
|
|
public $contact;
|
|
|
|
|
|
|
|
|
|
public function __construct($payment, $contact)
|
2020-02-15 09:01:15 +00:00
|
|
|
{
|
|
|
|
|
$this->payment = $payment;
|
2020-05-09 08:35:49 +10:00
|
|
|
|
|
|
|
|
$this->contact = $contact;
|
2020-02-15 09:01:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-09-06 19:38:10 +10:00
|
|
|
* Builds the correct template to send.
|
2020-10-28 21:10:49 +11:00
|
|
|
* @return void
|
2020-02-15 09:01:15 +00:00
|
|
|
*/
|
2020-05-09 08:35:49 +10:00
|
|
|
public function run()
|
2020-02-15 09:01:15 +00:00
|
|
|
{
|
2021-10-08 16:23:00 +11:00
|
|
|
$this->payment->load('company', 'client.contacts');
|
|
|
|
|
|
2022-08-04 16:22:48 +10:00
|
|
|
$contact = $this->payment->client->contacts()->first();
|
|
|
|
|
|
2022-08-04 16:41:56 +10:00
|
|
|
if ($contact?->email)
|
2022-08-04 16:22:48 +10:00
|
|
|
EmailPayment::dispatch($this->payment, $this->payment->company, $contact);
|
|
|
|
|
|
2020-02-15 09:01:15 +00:00
|
|
|
}
|
|
|
|
|
}
|