Listeners

This commit is contained in:
David Bomba 2019-04-20 11:19:43 +10:00
parent e494459823
commit 61b7481eda
3 changed files with 63 additions and 1 deletions

View File

@ -0,0 +1,30 @@
<?php
namespace App\Listeners\Client;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class CreatedClient
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event)
{
//
}
}

View File

@ -2,7 +2,9 @@
namespace App\Providers;
use App\Events\Client\ClientWasCreated;
use App\Events\User\UserCreated;
use App\Listeners\Client\CreatedClient;
use App\Listeners\SendVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
@ -16,7 +18,27 @@ class EventServiceProvider extends ServiceProvider
protected $listen = [
UserCreated::class => [
SendVerificationNotification::class,
]
],
// Clients
ClientWasCreated::class => [
CreatedClient::class,
'App\Listeners\SubscriptionListener@createdClient',
],
'App\Events\ClientWasArchived' => [
'App\Listeners\ActivityListener@archivedClient',
],
'App\Events\ClientWasUpdated' => [
'App\Listeners\SubscriptionListener@updatedClient',
],
'App\Events\ClientWasDeleted' => [
'App\Listeners\ActivityListener@deletedClient',
'App\Listeners\SubscriptionListener@deletedClient',
'App\Listeners\HistoryListener@deletedClient',
],
'App\Events\ClientWasRestored' => [
'App\Listeners\ActivityListener@restoredClient',
],
];
/**

View File

@ -587,6 +587,16 @@ class CreateUsersTable extends Migration
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
Schema::create('activities', function ($table) {
$table->increments('id');
$table->unsignedInteger('user_id');
$table->unsignedInteger('company_id');
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
});
}
/**