diff --git a/app/Http/routes.php b/app/Http/routes.php index 1e1ca6be8aa5..fd326be1a194 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -633,7 +633,13 @@ if (!defined('CONTACT_EMAIL')) { define('EVENT_CREATE_INVOICE', 2); define('EVENT_CREATE_QUOTE', 3); define('EVENT_CREATE_PAYMENT', 4); - define('EVENT_CREATE_VENDOR',5); + define('EVENT_CREATE_VENDOR', 5); + + // Added new events + define('EVENT_UPDATE_QUOTE', 6); + define('EVENT_DELETE_QUOTE', 7); + define('EVENT_UPDATE_INVOICE', 8); + define('EVENT_DELETE_INVOICE', 9); define('REQUESTED_PRO_PLAN', 'REQUESTED_PRO_PLAN'); define('DEMO_ACCOUNT_ID', 'DEMO_ACCOUNT_ID'); diff --git a/app/Listeners/SubscriptionListener.php b/app/Listeners/SubscriptionListener.php index 5b84413cb25a..3bf558a0a868 100644 --- a/app/Listeners/SubscriptionListener.php +++ b/app/Listeners/SubscriptionListener.php @@ -1,5 +1,8 @@ quote->account); + $this->checkSubscriptions(EVENT_UPDATE_QUOTE, $event->quote, $transformer, ENTITY_CLIENT); + } + + /** + * @param InvoiceWasUpdated $event + */ + public function updatedInvoice(InvoiceWasUpdated $event) + { + $transformer = new InvoiceTransformer($event->invoice->account); + $this->checkSubscriptions(EVENT_UPDATE_INVOICE, $event->invoice, $transformer, ENTITY_CLIENT); + } + + /** + * @param InvoiceWasDeleted $event + */ + public function deletedInvoice(InvoiceWasDeleted $event) + { + $transformer = new InvoiceTransformer($event->invoice->account); + $this->checkSubscriptions(EVENT_DELETE_INVOICE, $event->invoice, $transformer, ENTITY_CLIENT); } /** diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 5d0be86d36bc..4a23769092d6 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -36,6 +36,7 @@ class EventServiceProvider extends ServiceProvider { 'App\Events\InvoiceWasUpdated' => [ 'App\Listeners\ActivityListener@updatedInvoice', 'App\Listeners\InvoiceListener@updatedInvoice', + 'App\Listeners\SubscriptionListener@updatedInvoice', ], 'App\Events\InvoiceWasArchived' => [ 'App\Listeners\ActivityListener@archivedInvoice', @@ -67,6 +68,7 @@ class EventServiceProvider extends ServiceProvider { ], 'App\Events\QuoteWasUpdated' => [ 'App\Listeners\ActivityListener@updatedQuote', + 'App\Listeners\SubscriptionListener@updatedQuote', ], 'App\Events\QuoteWasArchived' => [ 'App\Listeners\ActivityListener@archivedQuote',