phpvms/app/Listeners/BidEventHandler.php
exciler d4c301a36c
Remove remove_bid_after_accept setting (#1100)
* Remove "Remove bid on accept" setting and remove bids after PIREP was filed

fixes #1039

* Add migration to remove setting from database

* fix migration naming and remove obsolete code

Co-authored-by: Andreas Palm <ap@ewsp.de>
2021-03-27 08:33:21 -04:00

39 lines
791 B
PHP

<?php
namespace App\Listeners;
use App\Contracts\Listener;
use App\Events\PirepFiled;
use App\Services\BidService;
/**
* Do stuff with bids - like if a PIREP is accepted, then remove the bid
*/
class BidEventHandler extends Listener
{
public static $callbacks = [
PirepFiled::class => 'onPirepFiled',
];
private $bidSvc;
public function __construct(BidService $bidSvc)
{
$this->bidSvc = $bidSvc;
}
/**
* When a PIREP is filed, remove any bids
*
* @param PirepFiled $event
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
* @throws \Exception
*/
public function onPirepFiled(PirepFiled $event): void
{
$this->bidSvc->removeBidForPirep($event->pirep);
}
}