Add Webhooks at send

This commit is contained in:
Lars Kusch 2023-02-03 12:46:55 +01:00 committed by GitHub
parent 73af36376a
commit 052ca31297
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -70,7 +70,14 @@ class MarkSent extends AbstractService
if($fire_webhook)
event('eloquent.updated: App\Models\Invoice', $this->invoice);
$subscriptions = Webhook::where('company_id', $invoice->company_id)
->where('event_id', Webhook::EVENT_SENT_INVOICE)
->exists();
if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_SENT_INVOICE, $this->invoice, $this->invoice->company, 'client')->delay(0);
}
return $this->invoice->fresh();
}