d4c301a36c
* 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>
39 lines
791 B
PHP
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);
|
|
}
|
|
}
|