diff --git a/app/Database/migrations/2021_03_25_213017_remove_setting_removebidonaccept.php b/app/Database/migrations/2021_03_25_213017_remove_setting_removebidonaccept.php new file mode 100644 index 00000000..25e25dae --- /dev/null +++ b/app/Database/migrations/2021_03_25_213017_remove_setting_removebidonaccept.php @@ -0,0 +1,19 @@ +where(['key' => 'pireps.remove_bid_on_accept']) + ->delete(); + } +} diff --git a/app/Database/seeds/settings.yml b/app/Database/seeds/settings.yml index 066936c5..ed04d7ca 100644 --- a/app/Database/seeds/settings.yml +++ b/app/Database/seeds/settings.yml @@ -263,13 +263,6 @@ options: '' type: boolean description: 'Only allow aircraft that are at the departure airport' -- key: pireps.remove_bid_on_accept - name: 'Remove bid on accept' - group: pireps - value: false - options: '' - type: boolean - description: 'When a PIREP is accepted, remove the bid, if it exists' - key: pireps.advanced_fuel name: 'Advanced Fuel Calculations' group: pireps diff --git a/app/Listeners/BidEventHandler.php b/app/Listeners/BidEventHandler.php index fff8affa..d7f9df79 100644 --- a/app/Listeners/BidEventHandler.php +++ b/app/Listeners/BidEventHandler.php @@ -3,8 +3,7 @@ namespace App\Listeners; use App\Contracts\Listener; -use App\Events\PirepAccepted; -use App\Events\PirepRejected; +use App\Events\PirepFiled; use App\Services\BidService; /** @@ -13,8 +12,7 @@ use App\Services\BidService; class BidEventHandler extends Listener { public static $callbacks = [ - PirepAccepted::class => 'onPirepAccept', - PirepRejected::class => 'onPirepReject', + PirepFiled::class => 'onPirepFiled', ]; private $bidSvc; @@ -25,29 +23,15 @@ class BidEventHandler extends Listener } /** - * When a PIREP is accepted, remove any bids + * When a PIREP is filed, remove any bids * - * @param PirepAccepted $event + * @param PirepFiled $event * * @throws \UnexpectedValueException * @throws \InvalidArgumentException * @throws \Exception */ - public function onPirepAccept(PirepAccepted $event): void - { - $this->bidSvc->removeBidForPirep($event->pirep); - } - - /** - * When a PIREP is accepted, remove any bids - * - * @param PirepRejected $event - * - * @throws \UnexpectedValueException - * @throws \InvalidArgumentException - * @throws \Exception - */ - public function onPirepReject(PirepRejected $event): void + public function onPirepFiled(PirepFiled $event): void { $this->bidSvc->removeBidForPirep($event->pirep); } diff --git a/app/Services/BidService.php b/app/Services/BidService.php index 134bbf44..bb4f12b7 100644 --- a/app/Services/BidService.php +++ b/app/Services/BidService.php @@ -169,10 +169,6 @@ class BidService extends Service */ public function removeBidForPirep(Pirep $pirep) { - if (!setting('pireps.remove_bid_on_accept')) { - return; - } - $flight = $pirep->flight; if (!$flight) { return; diff --git a/tests/PIREPTest.php b/tests/PIREPTest.php index 51fb7de3..8c288bb3 100644 --- a/tests/PIREPTest.php +++ b/tests/PIREPTest.php @@ -528,7 +528,6 @@ class PIREPTest extends TestCase { $bidSvc = app(BidService::class); $flightSvc = app(FlightService::class); - $this->settingsRepo->store('pireps.remove_bid_on_accept', true); $user = factory(User::class)->create([ 'flight_time' => 0, @@ -549,7 +548,7 @@ class PIREPTest extends TestCase ]); $pirep = $this->pirepSvc->create($pirep, []); - $this->pirepSvc->changeState($pirep, PirepState::ACCEPTED); + $this->pirepSvc->submit($pirep); $user_bid = Bid::where([ 'user_id' => $user->id,