From ec5bc577375def8c705395d7ba3ae428f1379a77 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 8 Feb 2023 07:09:47 +1100 Subject: [PATCH] Minor cleanup --- app/Models/BaseModel.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index 988928722164..08ad4823838d 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -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(); + ->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); } }