diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index b15649d23866..dadfa3e222ba 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -397,7 +397,7 @@ class Invoice extends BaseModel $storage_path = Storage::$type($this->client->invoice_filepath().$this->numberFormatter().'.pdf'); if (! Storage::exists($this->client->invoice_filepath().$this->numberFormatter().'.pdf')) { - event(new InvoiceWasUpdated($this, $this->company, Ninja::eventVars(auth()->user()->id))); + event(new InvoiceWasUpdated($this, $this->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); CreateEntityPdf::dispatchNow($invitation); } diff --git a/app/Models/InvoiceInvitation.php b/app/Models/InvoiceInvitation.php index 51042e7d70fa..3fa1f4918cf3 100644 --- a/app/Models/InvoiceInvitation.php +++ b/app/Models/InvoiceInvitation.php @@ -143,7 +143,7 @@ class InvoiceInvitation extends BaseModel $storage_path = Storage::url($this->invoice->client->invoice_filepath().$this->invoice->numberFormatter().'.pdf'); if (! Storage::exists($this->invoice->client->invoice_filepath().$this->invoice->numberFormatter().'.pdf')) { - event(new InvoiceWasUpdated($this->invoice, $this->company, Ninja::eventVars(auth()->user()->id))); + event(new InvoiceWasUpdated($this->invoice, $this->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); CreateEntityPdf::dispatchNow($this); } diff --git a/app/Services/Credit/ApplyPayment.php b/app/Services/Credit/ApplyPayment.php index 944e75cf46b7..0ebd7d6ab551 100644 --- a/app/Services/Credit/ApplyPayment.php +++ b/app/Services/Credit/ApplyPayment.php @@ -144,11 +144,11 @@ class ApplyPayment ->ledger() ->updateCreditBalance(($this->amount_applied * -1), "Credit payment applied to Invoice {$this->invoice->number}"); - event(new InvoiceWasUpdated($this->invoice, $this->invoice->company, Ninja::eventVars(auth()->user()->id))); + event(new InvoiceWasUpdated($this->invoice, $this->invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); if ((int)$this->invoice->balance == 0) { $this->invoice->service()->deletePdf(); - event(new InvoiceWasPaid($this->invoice, $this->payment, $this->payment->company, Ninja::eventVars(auth()->user()->id))); + event(new InvoiceWasPaid($this->invoice, $this->payment, $this->payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); } } } diff --git a/app/Services/Payment/UpdateInvoicePayment.php b/app/Services/Payment/UpdateInvoicePayment.php index 0af4a1e4311c..b9eda4fb7b12 100644 --- a/app/Services/Payment/UpdateInvoicePayment.php +++ b/app/Services/Payment/UpdateInvoicePayment.php @@ -87,7 +87,7 @@ class UpdateInvoicePayment InvoiceWorkflowSettings::dispatchNow($invoice); - event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars())); + event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); }); $this->payment->save();