mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-05 10:54:36 -04:00
62 lines
1.6 KiB
PHP
62 lines
1.6 KiB
PHP
<?php namespace app\Listeners;
|
|
|
|
use Auth;
|
|
use Utils;
|
|
|
|
use App\Events\ClientWasCreated;
|
|
use App\Events\QuoteWasCreated;
|
|
use App\Events\InvoiceWasCreated;
|
|
use App\Events\CreditWasCreated;
|
|
use App\Events\PaymentWasCreated;
|
|
|
|
use App\Events\VendorWasCreated;
|
|
use App\Events\ExpenseWasCreated;
|
|
|
|
class SubscriptionListener
|
|
{
|
|
public function createdClient(ClientWasCreated $event)
|
|
{
|
|
$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_CLIENT, $event->client);
|
|
}
|
|
|
|
public function createdQuote(QuoteWasCreated $event)
|
|
{
|
|
$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_QUOTE, $event->quote);
|
|
}
|
|
|
|
public function createdPayment(PaymentWasCreated $event)
|
|
{
|
|
$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_PAYMENT, $event->payment);
|
|
}
|
|
|
|
public function createdCredit(CreditWasCreated $event)
|
|
{
|
|
$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_CREDIT, $event->credit);
|
|
}
|
|
|
|
public function createdInvoice(InvoiceWasCreated $event)
|
|
{
|
|
$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_INVOICE, $event->invoice);
|
|
}
|
|
|
|
private function checkSubscriptions($activityTypeId, $entity)
|
|
{
|
|
$subscription = $entity->account->getSubscription($activityTypeId);
|
|
|
|
if ($subscription) {
|
|
Utils::notifyZapier($subscription, $entity);
|
|
}
|
|
}
|
|
|
|
public function createdVendor(VendorWasCreated $event)
|
|
{
|
|
$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_VENDOR, $event->vendor);
|
|
}
|
|
|
|
public function createdExpense(ExpenseWasCreated $event)
|
|
{
|
|
$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_EXPENSE, $event->expense);
|
|
}
|
|
|
|
}
|