Add additional events for PIREP states #436 (#548)

This commit is contained in:
Nabeel S 2020-02-11 13:56:20 -05:00 committed by GitHub
parent 39159e2c2e
commit f392bf1cb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,15 @@
<?php
namespace App\Events;
use App\Models\Pirep;
class PirepCancelled extends BaseEvent
{
public $pirep;
public function __construct(Pirep $pirep)
{
$this->pirep = $pirep;
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace App\Events;
use App\Models\Pirep;
class PirepPrefiled extends BaseEvent
{
public $pirep;
public function __construct(Pirep $pirep)
{
$this->pirep = $pirep;
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace App\Events;
use App\Models\Pirep;
class PirepUpdated extends BaseEvent
{
public $pirep;
public function __construct(Pirep $pirep)
{
$this->pirep = $pirep;
}
}

View File

@ -3,6 +3,8 @@
namespace App\Http\Controllers\Api;
use App\Contracts\Controller;
use App\Events\PirepPrefiled;
use App\Events\PirepUpdated;
use App\Exceptions\AircraftNotAtAirport;
use App\Exceptions\AircraftPermissionDenied;
use App\Exceptions\PirepCancelled;
@ -247,6 +249,8 @@ class PirepController extends Controller
$this->updateFields($pirep, $request);
$this->updateFares($pirep, $request);
event(new PirepPrefiled($pirep));
return new PirepResource($pirep);
}
@ -291,6 +295,8 @@ class PirepController extends Controller
$this->updateFields($pirep, $request);
$this->updateFares($pirep, $request);
event(new PirepUpdated($pirep));
return new PirepResource($pirep);
}

View File

@ -4,6 +4,7 @@ namespace App\Services;
use App\Contracts\Service;
use App\Events\PirepAccepted;
use App\Events\PirepCancelled;
use App\Events\PirepFiled;
use App\Events\PirepRejected;
use App\Events\UserStatsChanged;
@ -255,6 +256,8 @@ class PirepService extends Service
'status' => PirepStatus::CANCELLED,
], $pirep->id);
event(new PirepCancelled($pirep));
return $pirep;
}