mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Refactor Webhook to BaseModel.php
This commit is contained in:
parent
d0cfaff6d6
commit
400fb609ee
@ -12,6 +12,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\DataMapper\ClientSettings;
|
||||
use App\Jobs\Util\WebhookHandler;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\UserSessionAttributes;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
@ -205,4 +206,14 @@ class BaseModel extends Model
|
||||
return ctrans('texts.item');
|
||||
}
|
||||
|
||||
public function sendEvent($event_id, $additional_data){
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -73,13 +73,7 @@ class MarkSent extends AbstractService
|
||||
if($fire_webhook)
|
||||
event('eloquent.updated: App\Models\Invoice', $this->invoice);
|
||||
|
||||
$subscriptions = Webhook::where('company_id', $this->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);
|
||||
}
|
||||
$this->invoice->sendEvent(Webhook::EVENT_SENT_INVOICE, "client");
|
||||
|
||||
return $this->invoice->fresh();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user