mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Add event listeners
This commit is contained in:
parent
2191716115
commit
c593f2bd58
53
app/Listeners/Activity/ArchivedClientActivity.php
Normal file
53
app/Listeners/Activity/ArchivedClientActivity.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Listeners\Activity;
|
||||||
|
|
||||||
|
use App\Libraries\MultiDB;
|
||||||
|
use App\Models\Activity;
|
||||||
|
use App\Repositories\ActivityRepository;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
|
||||||
|
class ArchivedClientActivity implements ShouldQueue
|
||||||
|
{
|
||||||
|
protected $activity_repo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(ActivityRepository $activity_repo)
|
||||||
|
{
|
||||||
|
$this->activity_repo = $activity_repo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param object $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle($event)
|
||||||
|
{
|
||||||
|
MultiDB::setDb($event->company->db);
|
||||||
|
|
||||||
|
$fields = new \stdClass;
|
||||||
|
|
||||||
|
$fields->client_id = $event->client->id;
|
||||||
|
$fields->user_id = $event->client->user_id;
|
||||||
|
$fields->company_id = $event->client->company_id;
|
||||||
|
$fields->activity_type_id = Activity::ARCHIVE_CLIENT;
|
||||||
|
|
||||||
|
$this->activity_repo->save($fields, $event->client, $event->event_vars);
|
||||||
|
}
|
||||||
|
}
|
53
app/Listeners/Activity/DeleteClientActivity.php
Normal file
53
app/Listeners/Activity/DeleteClientActivity.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Listeners\Activity;
|
||||||
|
|
||||||
|
use App\Libraries\MultiDB;
|
||||||
|
use App\Models\Activity;
|
||||||
|
use App\Repositories\ActivityRepository;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
|
||||||
|
class DeleteClientActivity implements ShouldQueue
|
||||||
|
{
|
||||||
|
protected $activity_repo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(ActivityRepository $activity_repo)
|
||||||
|
{
|
||||||
|
$this->activity_repo = $activity_repo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param object $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle($event)
|
||||||
|
{
|
||||||
|
MultiDB::setDb($event->company->db);
|
||||||
|
|
||||||
|
$fields = new \stdClass;
|
||||||
|
|
||||||
|
$fields->client_id = $event->client->id;
|
||||||
|
$fields->user_id = $event->client->user_id;
|
||||||
|
$fields->company_id = $event->client->company_id;
|
||||||
|
$fields->activity_type_id = Activity::DELETE_CLIENT;
|
||||||
|
|
||||||
|
$this->activity_repo->save($fields, $event->client, $event->event_vars);
|
||||||
|
}
|
||||||
|
}
|
53
app/Listeners/Activity/RestoreClientActivity.php
Normal file
53
app/Listeners/Activity/RestoreClientActivity.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Listeners\Activity;
|
||||||
|
|
||||||
|
use App\Libraries\MultiDB;
|
||||||
|
use App\Models\Activity;
|
||||||
|
use App\Repositories\ActivityRepository;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
|
||||||
|
class RestoreClientActivity implements ShouldQueue
|
||||||
|
{
|
||||||
|
protected $activity_repo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(ActivityRepository $activity_repo)
|
||||||
|
{
|
||||||
|
$this->activity_repo = $activity_repo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param object $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle($event)
|
||||||
|
{
|
||||||
|
MultiDB::setDb($event->company->db);
|
||||||
|
|
||||||
|
$fields = new \stdClass;
|
||||||
|
|
||||||
|
$fields->client_id = $event->client->id;
|
||||||
|
$fields->user_id = $event->client->user_id;
|
||||||
|
$fields->company_id = $event->client->company_id;
|
||||||
|
$fields->activity_type_id = Activity::RESTORE_CLIENT;
|
||||||
|
|
||||||
|
$this->activity_repo->save($fields, $event->client, $event->event_vars);
|
||||||
|
}
|
||||||
|
}
|
@ -15,12 +15,12 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
|
|
||||||
class Activity extends StaticModel
|
class Activity extends StaticModel
|
||||||
{
|
{
|
||||||
const CREATE_CLIENT=1;
|
const CREATE_CLIENT=1; //
|
||||||
const ARCHIVE_CLIENT=2;
|
const ARCHIVE_CLIENT=2; //
|
||||||
const DELETE_CLIENT=3;
|
const DELETE_CLIENT=3; //
|
||||||
const CREATE_INVOICE=4;
|
const CREATE_INVOICE=4; //
|
||||||
const UPDATE_INVOICE=5;
|
const UPDATE_INVOICE=5; //
|
||||||
const EMAIL_INVOICE=6;
|
const EMAIL_INVOICE=6; //
|
||||||
const VIEW_INVOICE=7;
|
const VIEW_INVOICE=7;
|
||||||
const ARCHIVE_INVOICE=8;
|
const ARCHIVE_INVOICE=8;
|
||||||
const DELETE_INVOICE=9;
|
const DELETE_INVOICE=9;
|
||||||
|
@ -41,11 +41,14 @@ use App\Events\Quote\QuoteWasApproved;
|
|||||||
use App\Events\User\UserLoggedIn;
|
use App\Events\User\UserLoggedIn;
|
||||||
use App\Events\User\UserWasCreated;
|
use App\Events\User\UserWasCreated;
|
||||||
use App\Events\User\UserWasDeleted;
|
use App\Events\User\UserWasDeleted;
|
||||||
|
use App\Listeners\Activity\ArchivedClientActivity;
|
||||||
use App\Listeners\Activity\CreatedClientActivity;
|
use App\Listeners\Activity\CreatedClientActivity;
|
||||||
|
use App\Listeners\Activity\DeleteClientActivity;
|
||||||
use App\Listeners\Activity\PaymentCreatedActivity;
|
use App\Listeners\Activity\PaymentCreatedActivity;
|
||||||
use App\Listeners\Activity\PaymentDeletedActivity;
|
use App\Listeners\Activity\PaymentDeletedActivity;
|
||||||
use App\Listeners\Activity\PaymentRefundedActivity;
|
use App\Listeners\Activity\PaymentRefundedActivity;
|
||||||
use App\Listeners\Activity\PaymentVoidedActivity;
|
use App\Listeners\Activity\PaymentVoidedActivity;
|
||||||
|
use App\Listeners\Activity\RestoreClientActivity;
|
||||||
use App\Listeners\Contact\UpdateContactLastLogin;
|
use App\Listeners\Contact\UpdateContactLastLogin;
|
||||||
use App\Listeners\Document\DeleteCompanyDocuments;
|
use App\Listeners\Document\DeleteCompanyDocuments;
|
||||||
use App\Listeners\Invoice\CreateInvoiceActivity;
|
use App\Listeners\Invoice\CreateInvoiceActivity;
|
||||||
@ -105,12 +108,15 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
CreatedClientActivity::class,
|
CreatedClientActivity::class,
|
||||||
],
|
],
|
||||||
ClientWasArchived::class =>[
|
ClientWasArchived::class =>[
|
||||||
|
ArchivedClientActivity::class,
|
||||||
],
|
],
|
||||||
ClientWasUpdated::class =>[
|
ClientWasUpdated::class =>[
|
||||||
],
|
],
|
||||||
ClientWasDeleted::class =>[
|
ClientWasDeleted::class =>[
|
||||||
|
DeleteClientActivity::class,
|
||||||
],
|
],
|
||||||
ClientWasRestored::class =>[
|
ClientWasRestored::class =>[
|
||||||
|
RestoreClientActivity::class,
|
||||||
],
|
],
|
||||||
// Documents
|
// Documents
|
||||||
DocumentWasCreated::class =>[
|
DocumentWasCreated::class =>[
|
||||||
|
Loading…
x
Reference in New Issue
Block a user