1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Minor cleanup

This commit is contained in:
David Bomba 2023-02-08 07:09:47 +11:00
parent 0de3b4a0ff
commit ec5bc57737

View File

@ -206,12 +206,22 @@ class BaseModel extends Model
return ctrans('texts.item');
}
public function sendEvent($event_id, $additional_data=""){
/**
* Model helper to send events for webhooks
*
* @param int $event_id
* @param string $additional_data optional includes
*
* @return void
*/
public function sendEvent(int $event_id, string $additional_data = ""): void
{
$subscriptions = Webhook::where('company_id', $this->company_id)
->where('event_id', $event_id)
->exists();
if ($subscriptions) {
WebhookHandler::dispatch($event_id, $this, $this->company, $additional_data)->delay(0);
WebhookHandler::dispatch($event_id, $this, $this->company, $additional_data);
}
}