parent
57e91027c8
commit
e4b1c238f3
21
app/Events/AcarsUpdate.php
Normal file
21
app/Events/AcarsUpdate.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers\Api;
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Contracts\Controller;
|
use App\Contracts\Controller;
|
||||||
|
use App\Events\AcarsUpdate;
|
||||||
use App\Exceptions\PirepCancelled;
|
use App\Exceptions\PirepCancelled;
|
||||||
use App\Http\Requests\Acars\EventRequest;
|
use App\Http\Requests\Acars\EventRequest;
|
||||||
use App\Http\Requests\Acars\LogRequest;
|
use App\Http\Requests\Acars\LogRequest;
|
||||||
@ -198,6 +199,9 @@ class AcarsController extends Controller
|
|||||||
|
|
||||||
$pirep->save();
|
$pirep->save();
|
||||||
|
|
||||||
|
// Post a new update for this ACARS position
|
||||||
|
event(new AcarsUpdate($pirep, $pirep->position));
|
||||||
|
|
||||||
return $this->message($count.' positions added', $count);
|
return $this->message($count.' positions added', $count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
25
modules/Vacentral/Listeners/AcarsUpdateListener.php
Normal file
25
modules/Vacentral/Listeners/AcarsUpdateListener.php
Normal 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]);
|
||||||
|
}
|
||||||
|
}
|
@ -3,12 +3,14 @@
|
|||||||
namespace Modules\Vacentral\Listeners;
|
namespace Modules\Vacentral\Listeners;
|
||||||
|
|
||||||
use App\Events\PirepAccepted;
|
use App\Events\PirepAccepted;
|
||||||
use Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class PirepAcceptedEventListener
|
class PirepAcceptedEventListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Handle the event.
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param PirepAccepted $pirep
|
||||||
*/
|
*/
|
||||||
public function handle(PirepAccepted $pirep)
|
public function handle(PirepAccepted $pirep)
|
||||||
{
|
{
|
||||||
|
@ -2,16 +2,16 @@
|
|||||||
|
|
||||||
namespace Modules\Vacentral\Providers;
|
namespace Modules\Vacentral\Providers;
|
||||||
|
|
||||||
|
use App\Events\AcarsUpdate;
|
||||||
use App\Events\PirepAccepted;
|
use App\Events\PirepAccepted;
|
||||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||||
|
use Modules\Vacentral\Listeners\AcarsUpdateListener;
|
||||||
use Modules\Vacentral\Listeners\PirepAcceptedEventListener;
|
use Modules\Vacentral\Listeners\PirepAcceptedEventListener;
|
||||||
|
|
||||||
class EventServiceProvider extends ServiceProvider
|
class EventServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The event listener mappings for the application.
|
|
||||||
*/
|
|
||||||
protected $listen = [
|
protected $listen = [
|
||||||
|
AcarsUpdate::class => [AcarsUpdateListener::class],
|
||||||
PirepAccepted::class => [PirepAcceptedEventListener::class],
|
PirepAccepted::class => [PirepAcceptedEventListener::class],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user