Minor fixes

This commit is contained in:
Lars Kusch 2023-02-07 15:46:52 +01:00
parent 400fb609ee
commit f0c6df6c4a
4 changed files with 4 additions and 20 deletions

View File

@ -206,7 +206,7 @@ class BaseModel extends Model
return ctrans('texts.item');
}
public function sendEvent($event_id, $additional_data){
public function sendEvent($event_id, $additional_data=""){
$subscriptions = Webhook::where('company_id', $this->company_id)
->where('event_id', $event_id)
->exists();

View File

@ -54,13 +54,7 @@ class MarkSent
event(new CreditWasMarkedSent($this->credit, $this->credit->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
$subscriptions = Webhook::where('company_id', $this->credit->company_id)
->where('event_id', Webhook::EVENT_SENT_CREDIT)
->exists();
if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_SENT_CREDIT, $this->credit, $this->credit->company)->delay(0);
}
$this->credit->sendEvent(Webhook::EVENT_SENT_CREDIT);
return $this->credit;
}

View File

@ -45,12 +45,7 @@ class MarkSent
->adjustBalance($this->purchase_order->amount) //why was this commented out previously?
->save();
$subscriptions = Webhook::where('company_id', $this->purchase_order->company_id)
->where('event_id', Webhook::EVENT_SENT_PURCHASE_ORDER)
->exists();
if ($subscriptions)
WebhookHandler::dispatch(Webhook::EVENT_SENT_PURCHASE_ORDER, $this->purchase_order, $this->purchase_order->company, 'vendor')->delay(0);
$this->purchase_order->sendEvent(Webhook::EVENT_SENT_PURCHASE_ORDER, "vendor");
return $this->purchase_order;
}

View File

@ -54,12 +54,7 @@ class MarkSent
event(new QuoteWasMarkedSent($this->quote, $this->quote->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
$subscriptions = Webhook::where('company_id', $this->quote->company_id)
->where('event_id', Webhook::EVENT_SENT_QUOTE)
->exists();
if ($subscriptions)
WebhookHandler::dispatch(Webhook::EVENT_SENT_QUOTE, $this->quote, $this->quote->company, 'client')->delay(0);
$this->quote->sendEvent(Webhook::EVENT_SENT_QUOTE, "client");
return $this->quote;
}