phpvms/app/Listeners/BidEvents.php
Nabeel S f5183babf6
#406 Refactor bids (#432)
* Add flight_id column to pireps table

* Refactor PIREPs and bids closes 406

* Formatting
2019-11-05 11:44:31 -05:00

47 lines
985 B
PHP

<?php
namespace App\Listeners;
use App\Contracts\Listener;
use App\Events\PirepAccepted;
use App\Services\BidService;
use Illuminate\Contracts\Events\Dispatcher;
/**
* Do stuff with bids - like if a PIREP is accepted, then remove the bid
*/
class BidEvents extends Listener
{
private $bidSvc;
public function __construct(BidService $bidSvc)
{
$this->bidSvc = $bidSvc;
}
/**
* @param $events
*/
public function subscribe(Dispatcher $events): void
{
$events->listen(
PirepAccepted::class,
'App\Listeners\BidEvents@onPirepAccept'
);
}
/**
* When a PIREP is accepted, remove any bids
*
* @param PirepAccepted $event
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
* @throws \Exception
*/
public function onPirepAccept(PirepAccepted $event): void
{
$this->bidSvc->removeBidForPirep($event->pirep);
}
}