this is my scenario: I have a Laravel queued jod, here the handle method content:
$invoiceContract = app('AsteBolaffi\Repositories\Backend\Invoice\InvoiceContract');
$error = $invoiceContract->recordInvoice($this->invoiceId);
d($error);
if (!empty($error) && !empty($this->userEmail)) {
$userEmail = $this->userEmail;
$invoice = $invoiceContract->findOrThrowException($this->invoiceId);
$invoice->load('customer');
d("Going to send mail to " . $userEmail);
d($error);
d($invoice->customer->business_name);
$data["error"] = $error;
$data["business_name"] = $invoice->customer->business_name;
$data["document_number"] = $invoice->document_number;
d($data);
\Mail::queueOn('mail', "emails.record_invoice", $data, function ($message) use ($userEmail) {
$message->from('[email protected]', 'AsteBolaffi');
$message->to($userEmail);
$message->subject('Errori contabilizzazione fattura');
d("HERE I AM");
});
d("Completed");
}
return;
If the recordInvoice method returns a value (e.g. "Item not found") the if clause is satisfied and it has to add a mail queue. But the mail queue is not created on db and the current job is not deleted even if the console prints the last d method value ("Completed"). If recordInvoice does not returns any error the job is deleted.
Non-sense thing (at least for me)
If I comment the recordInvoice method and set a value to error, for example:
$error = "test";
It works properly, adds the mail queue and deletes the current one.
Any tip about it?
I don't know why, but moving the project from php 5.6 to 7.0 it works correctly.