Add ACARS update event #755 (#756)

This commit is contained in:
Nabeel S 2020-06-09 06:10:40 -07:00 committed by GitHub
parent 57e91027c8
commit e4b1c238f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 56 additions and 4 deletions

View File

@ -0,0 +1,21 @@
<?php
namespace App\Events;
use App\Models\Acars;
use App\Models\Pirep;
class AcarsUpdate extends BaseEvent
{
/** @var Pirep */
public $pirep;
/** @var Acars */
public $acars;
public function __construct(Pirep $pirep, Acars $acars)
{
$this->pirep = $pirep;
$this->acars = $acars;
}
}

View File

@ -3,6 +3,7 @@
namespace App\Http\Controllers\Api;
use App\Contracts\Controller;
use App\Events\AcarsUpdate;
use App\Exceptions\PirepCancelled;
use App\Http\Requests\Acars\EventRequest;
use App\Http\Requests\Acars\LogRequest;
@ -198,6 +199,9 @@ class AcarsController extends Controller
$pirep->save();
// Post a new update for this ACARS position
event(new AcarsUpdate($pirep, $pirep->position));
return $this->message($count.' positions added', $count);
}

View File

@ -0,0 +1,25 @@
<?php
namespace Modules\Vacentral\Listeners;
use App\Events\AcarsUpdate;
use Illuminate\Support\Facades\Log;
use VaCentral\Contracts\IVaCentral;
class AcarsUpdateListener
{
private $vacentral;
public function __construct(IVaCentral $vacentral)
{
$this->vacentral = $vacentral;
}
/**
* @param AcarsUpdate $event
*/
public function handle(AcarsUpdate $event)
{
Log::info('Received acars update event', [$event]);
}
}

View File

@ -3,12 +3,14 @@
namespace Modules\Vacentral\Listeners;
use App\Events\PirepAccepted;
use Log;
use Illuminate\Support\Facades\Log;
class PirepAcceptedEventListener
{
/**
* Handle the event.
*
* @param PirepAccepted $pirep
*/
public function handle(PirepAccepted $pirep)
{

View File

@ -2,16 +2,16 @@
namespace Modules\Vacentral\Providers;
use App\Events\AcarsUpdate;
use App\Events\PirepAccepted;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Modules\Vacentral\Listeners\AcarsUpdateListener;
use Modules\Vacentral\Listeners\PirepAcceptedEventListener;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*/
protected $listen = [
AcarsUpdate::class => [AcarsUpdateListener::class],
PirepAccepted::class => [PirepAcceptedEventListener::class],
];
}