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>
This commit is contained in:
parent
c2b0b69eb2
commit
d4c301a36c
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class RemoveSettingRemoveBidOnAccept extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
DB::table('settings')
|
||||
->where(['key' => 'pireps.remove_bid_on_accept'])
|
||||
->delete();
|
||||
}
|
||||
}
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user