mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Set DB on listeners
This commit is contained in:
parent
245980ce4b
commit
e27a52c59d
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Listeners\Activity;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Repositories\ActivityRepository;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@ -19,6 +20,7 @@ use Illuminate\Queue\InteractsWithQueue;
|
||||
class CreatedClientActivity implements ShouldQueue
|
||||
{
|
||||
protected $activity_repo;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
@ -37,6 +39,8 @@ class CreatedClientActivity implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->client_id = $event->client->id;
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace App\Listeners\Activity;
|
||||
|
||||
use App\Jobs\Invoice\InvoiceWorkflowSettings;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
@ -21,15 +22,15 @@ use Illuminate\Queue\InteractsWithQueue;
|
||||
|
||||
class PaymentCreatedActivity implements ShouldQueue
|
||||
{
|
||||
protected $activityRepo;
|
||||
protected $activity_repo;
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(ActivityRepository $activityRepo)
|
||||
public function __construct(ActivityRepository $activity_repo)
|
||||
{
|
||||
$this->activityRepo = $activityRepo;
|
||||
$this->activity_repo = $activity_repo;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,6 +41,8 @@ class PaymentCreatedActivity implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$payment = $event->payment;
|
||||
|
||||
$invoices = $payment->invoices;
|
||||
@ -57,11 +60,11 @@ class PaymentCreatedActivity implements ShouldQueue
|
||||
|
||||
InvoiceWorkflowSettings::dispatchNow($invoice);
|
||||
|
||||
$this->activityRepo->save($fields, $invoice);
|
||||
$this->activity_repo->save($fields, $invoice);
|
||||
}
|
||||
|
||||
if (count($invoices) == 0) {
|
||||
$this->activityRepo->save($fields, $payment);
|
||||
$this->activity_repo->save($fields, $payment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Listeners\Activity;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
@ -20,15 +21,16 @@ use Illuminate\Queue\InteractsWithQueue;
|
||||
|
||||
class PaymentDeletedActivity implements ShouldQueue
|
||||
{
|
||||
protected $activityRepo;
|
||||
protected $activity_repo;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(ActivityRepository $activityRepo)
|
||||
public function __construct(ActivityRepository $activity_repo)
|
||||
{
|
||||
$this->activityRepo = $activityRepo;
|
||||
$this->activity_repo = $activity_repo;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -39,6 +41,8 @@ class PaymentDeletedActivity implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$payment = $event->payment;
|
||||
|
||||
$invoices = $payment->invoices;
|
||||
@ -54,11 +58,11 @@ class PaymentDeletedActivity implements ShouldQueue
|
||||
foreach ($invoices as $invoice) { //todo we may need to add additional logic if in the future we apply payments to other entity Types, not just invoices
|
||||
$fields->invoice_id = $invoice->id;
|
||||
|
||||
$this->activityRepo->save($fields, $invoice);
|
||||
$this->activity_repo->save($fields, $invoice);
|
||||
}
|
||||
|
||||
if (count($invoices) == 0) {
|
||||
$this->activityRepo->save($fields, $payment);
|
||||
$this->activity_repo->save($fields, $payment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Listeners\Activity;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Repositories\ActivityRepository;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@ -37,6 +38,8 @@ class PaymentRefundedActivity implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->client_id = $event->payment->id;
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Listeners\Activity;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Repositories\ActivityRepository;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@ -19,6 +20,7 @@ use Illuminate\Queue\InteractsWithQueue;
|
||||
class PaymentVoidedActivity implements ShouldQueue
|
||||
{
|
||||
protected $activity_repo;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
@ -37,6 +39,8 @@ class PaymentVoidedActivity implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->client_id = $event->payment->id;
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Listeners\Contact;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Repositories\ActivityRepository;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@ -35,6 +36,8 @@ class UpdateContactLastLogin implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$client_contact = $event->client_contact;
|
||||
|
||||
$client_contact->last_login = now();
|
||||
|
@ -13,6 +13,7 @@ namespace App\Listeners\Credit;
|
||||
|
||||
use App\Factory\CreditInvitationFactory;
|
||||
use App\Factory\InvoiceInvitationFactory;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\CreditInvitation;
|
||||
use App\Models\InvoiceInvitation;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
@ -34,6 +35,8 @@ class CreateCreditInvitation implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$credit = $event->credit;
|
||||
|
||||
$contacts = $credit->client->contacts;
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Listeners\Document;
|
||||
|
||||
use App\Events\Company\CompanyWasDeleted;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Document;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
@ -29,6 +30,9 @@ class DeleteCompanyDocuments
|
||||
*/
|
||||
public function handle(CompanyWasDeleted $event)
|
||||
{
|
||||
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$path = sprintf('%s/%s', storage_path('app/public'), $event->company->company_key);
|
||||
|
||||
// Remove all files & folders, under company's path.
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Listeners\Invoice;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\InvoiceInvitation;
|
||||
@ -41,6 +42,8 @@ class CreateInvoiceActivity implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->invoice_id = $event->invoice->id;
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace App\Listeners\Invoice;
|
||||
|
||||
use App\Factory\InvoiceInvitationFactory;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\InvoiceInvitation;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@ -32,6 +33,8 @@ class CreateInvoiceInvitation implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$invoice = $event->invoice;
|
||||
|
||||
$contacts = $invoice->client->contacts;
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace App\Listeners\Invoice;
|
||||
|
||||
use App\Jobs\Invoice\CreateInvoicePdf as PdfCreator;
|
||||
use App\Libraries\MultiDB;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
|
||||
@ -35,6 +36,9 @@ class CreateInvoicePdf implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$event->invoice->invitations->each(function ($invitation) {
|
||||
|
||||
PdfCreator::dispatch($invitation);
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Listeners\Invoice;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\InvoiceInvitation;
|
||||
@ -41,6 +42,9 @@ class InvoiceCancelledActivity implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->invoice_id = $event->invoice->id;
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Listeners\Invoice;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\InvoiceInvitation;
|
||||
@ -41,6 +42,9 @@ class InvoiceDeletedActivity implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->invoice_id = $event->invoice->id;
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Listeners\Invoice;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\InvoiceInvitation;
|
||||
@ -41,6 +42,8 @@ class InvoiceEmailActivity implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->invoice_id = $event->invitation->invoice->id;
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Listeners\Invoice;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\InvoiceInvitation;
|
||||
@ -41,6 +42,8 @@ class InvoiceEmailFailedActivity implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->invoice_id = $event->invoice->id;
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace App\Listeners\Invoice;
|
||||
|
||||
use App\Jobs\Mail\EntitySentMailer;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\InvoiceInvitation;
|
||||
@ -41,7 +42,8 @@ class InvoiceEmailedNotification implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
$invitation = $event->invitation;
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
|
||||
foreach ($invitation->company->company_users as $company_user) {
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Listeners\Invoice;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\InvoiceInvitation;
|
||||
@ -41,6 +42,8 @@ class InvoiceReversedActivity implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->invoice_id = $event->invoice->id;
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Listeners\Invoice;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Invoice;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
@ -35,6 +36,8 @@ class UpdateInvoiceInvitations implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$payment = $event->payment;
|
||||
$invoices = $payment->invoices;
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace App\Listeners\Misc;
|
||||
|
||||
use App\Jobs\Mail\EntityViewedMailer;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Notifications\Admin\EntityViewedNotification;
|
||||
use App\Utils\Traits\Notifications\UserNotifies;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@ -39,6 +40,8 @@ class InvitationViewedListener implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$entity_name = $event->entity;
|
||||
$invitation = $event->invitation;
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace App\Listeners\Payment;
|
||||
|
||||
use App\Jobs\Mail\EntityPaidMailer;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
@ -43,6 +44,8 @@ class PaymentNotification implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$payment = $event->payment;
|
||||
|
||||
/*User notifications*/
|
||||
|
@ -14,6 +14,7 @@ namespace App\Listeners\Quote;
|
||||
use App\Factory\CreditInvitationFactory;
|
||||
use App\Factory\InvoiceInvitationFactory;
|
||||
use App\Factory\QuoteInvitationFactory;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\InvoiceInvitation;
|
||||
use App\Models\QuoteInvitation;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
@ -35,6 +36,8 @@ class CreateQuoteInvitation implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$quote = $event->credit;
|
||||
|
||||
$contacts = $quote->client->contacts;
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Listeners\Quote;
|
||||
|
||||
use App\Jobs\Quote\QuoteWorkflowSettings;
|
||||
use App\Libraries\MultiDB;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
|
||||
@ -26,6 +27,8 @@ class ReachWorkflowSettings
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
QuoteWorkflowSettings::dispatchNow($event->quote);
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Listeners\User;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Repositories\ActivityRepository;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@ -37,6 +38,8 @@ class ArchivedUserActivity implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$fields = new \stdClass;
|
||||
|
||||
if (auth()->user()->id) {
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Listeners\User;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Repositories\ActivityRepository;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@ -37,6 +38,8 @@ class CreatedUserActivity implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$fields = new \stdClass;
|
||||
|
||||
if (auth()->user()) {
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Listeners\User;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Repositories\ActivityRepository;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
@ -42,6 +43,8 @@ class DeletedUserActivity implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$fields = new \stdClass;
|
||||
|
||||
if (auth()->user()->id) {
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Listeners\User;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Repositories\ActivityRepository;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@ -37,6 +38,8 @@ class RestoredUserActivity implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$fields = new \stdClass;
|
||||
|
||||
if (auth()->user()->id) {
|
||||
|
@ -11,12 +11,13 @@
|
||||
|
||||
namespace App\Listeners\User;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Repositories\ActivityRepository;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class UpdateUserLastLogin implements ShouldQueue
|
||||
@ -40,6 +41,8 @@ class UpdateUserLastLogin implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$user = $event->user;
|
||||
|
||||
$user->last_login = now();
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Listeners\User;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Repositories\ActivityRepository;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@ -37,6 +38,8 @@ class UpdatedUserActivity implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$fields = new \stdClass;
|
||||
|
||||
if (auth()->user()->id) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user