144 - Testing the Event Listener

This commit is contained in:
Adam Wathan
2017-11-14 16:41:09 -05:00
parent 5e45bfc693
commit 6e1924e5c9
4 changed files with 90 additions and 2 deletions

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class ProcessPosterImage implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $concert;
public function __construct($concert)
{
$this->concert = $concert;
}
public function handle()
{
//
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Listeners;
use App\Events\ConcertAdded;
use App\Jobs\ProcessPosterImage;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class SchedulePosterImageProcessing
{
public function handle(ConcertAdded $event)
{
if ($event->concert->hasPoster()) {
ProcessPosterImage::dispatch($event->concert);
}
}
}

View File

@@ -13,8 +13,8 @@ class EventServiceProvider extends ServiceProvider
* @var array
*/
protected $listen = [
'App\Events\SomeEvent' => [
'App\Listeners\EventListener',
'App\Events\ConcertAdded' => [
'App\Listeners\SchedulePosterImageProcessing',
],
];