1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/Jobs/Quote/EmailQuote.php
David Bomba 6a7079b0be
Implement Github actions (#3547)
* Update phpunit.yml

* Update phpunit.yml

* Update .env.ci

* Update phpunit.yml

* Update .env.ci

* Update phpunit.yml

* Update phpunit.yml

* Update phpunit.yml

* Update phpunit.yml

* Update .env.ci

* Update phpunit.yml

* Update phpunit.yml

* Update phpunit.yml

* Update phpunit.yml

* Force /setup if system requirements are not met

* Update .env.ci

* Update phpunit.yml

* Minor changes for github actions"

* Fixes for github actions

* Fixes for github actions

* Fixes for github actions

* Fixes for github actions

* Fixes for github actions

* Fixes for github actions

* Fixes for github actions

* Fixes for github actions

* cs-fixer

* cs-fixer

* Fixes for github actions

* db ports github actions

* Refactor the template engine
2020-03-26 14:23:57 +11:00

75 lines
2.0 KiB
PHP

<?php
namespace App\Jobs\Quote;
use App\Events\Invoice\InvoiceWasEmailed;
use App\Events\Invoice\InvoiceWasEmailedAndFailed;
use App\Events\Quote\QuoteWasEmailed;
use App\Events\Quote\QuoteWasEmailedAndFailed;
use App\Jobs\Utils\SystemLogger;
use App\Libraries\MultiDB;
use App\Mail\TemplateEmail;
use App\Models\Company;
use App\Models\Quote;
use App\Models\QuoteInvitation;
use App\Models\SystemLog;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Mail;
class EmailQuote implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $quote_invitation;
public $email_builder;
/**
* EmailQuote constructor.
* @param BuildEmail $email_builder
* @param QuoteInvitation $quote_invitation
*/
public function __construct($email_builder, QuoteInvitation $quote_invitation)
{
$this->quote_invitation = $quote_invitation;
$this->email_builder = $email_builder;
}
/**
* Execute the job.
*
*
* @return void
*/
public function handle()
{
Mail::to($this->quote_invitation->contact->email, $this->quote_invitation->contact->present()->name())
->send(
new TemplateEmail(
$this->email_builder,
$this->quote_invitation->contact->user,
$this->quote_invitation->contact->client
)
);
if (count(Mail::failures()) > 0) {
return $this->logMailError(Mail::failures());
}
}
private function logMailError($errors)
{
SystemLogger::dispatch(
$errors,
SystemLog::CATEGORY_MAIL,
SystemLog::EVENT_MAIL_SEND,
SystemLog::TYPE_FAILURE,
$this->quote->client
);
}
}