Apply fixes from StyleCI
This commit is contained in:
committed by
StyleCI Bot
parent
20f46adbc4
commit
9596d88b48
@@ -14,17 +14,17 @@ use Log;
|
||||
|
||||
/**
|
||||
* Class FlightService
|
||||
* @package App\Services
|
||||
*/
|
||||
class FlightService extends Service
|
||||
{
|
||||
private $fareSvc,
|
||||
$flightRepo,
|
||||
$navDataRepo,
|
||||
$userSvc;
|
||||
private $fareSvc;
|
||||
private $flightRepo;
|
||||
private $navDataRepo;
|
||||
private $userSvc;
|
||||
|
||||
/**
|
||||
* FlightService constructor.
|
||||
*
|
||||
* @param FareService $fareSvc
|
||||
* @param FlightRepository $flightRepo
|
||||
* @param NavdataRepository $navdataRepo
|
||||
@@ -35,8 +35,7 @@ class FlightService extends Service
|
||||
FlightRepository $flightRepo,
|
||||
NavdataRepository $navdataRepo,
|
||||
UserService $userSvc
|
||||
)
|
||||
{
|
||||
) {
|
||||
$this->fareSvc = $fareSvc;
|
||||
$this->flightRepo = $flightRepo;
|
||||
$this->navDataRepo = $navdataRepo;
|
||||
@@ -45,7 +44,9 @@ class FlightService extends Service
|
||||
|
||||
/**
|
||||
* Filter out any flights according to different settings
|
||||
*
|
||||
* @param $user
|
||||
*
|
||||
* @return FlightRepository
|
||||
*/
|
||||
public function filterFlights($user)
|
||||
@@ -61,15 +62,17 @@ class FlightService extends Service
|
||||
|
||||
/**
|
||||
* Filter out subfleets to only include aircraft that a user has access to
|
||||
*
|
||||
* @param $user
|
||||
* @param $flight
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function filterSubfleets($user, $flight)
|
||||
{
|
||||
$subfleets = $flight->subfleets;
|
||||
|
||||
/**
|
||||
/*
|
||||
* Only allow aircraft that the user has access to in their rank
|
||||
*/
|
||||
if (setting('pireps.restrict_aircraft_to_rank', false)) {
|
||||
@@ -81,7 +84,7 @@ class FlightService extends Service
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* Only allow aircraft that are at the current departure airport
|
||||
*/
|
||||
if (setting('pireps.only_aircraft_at_dpt_airport', false)) {
|
||||
@@ -103,7 +106,9 @@ class FlightService extends Service
|
||||
|
||||
/**
|
||||
* Check if this flight has a duplicate already
|
||||
*
|
||||
* @param Flight $flight
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isFlightDuplicate(Flight $flight)
|
||||
@@ -140,7 +145,9 @@ class FlightService extends Service
|
||||
|
||||
/**
|
||||
* Delete a flight, and all the user bids, etc associated with it
|
||||
*
|
||||
* @param Flight $flight
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function deleteFlight(Flight $flight): void
|
||||
@@ -152,6 +159,7 @@ class FlightService extends Service
|
||||
|
||||
/**
|
||||
* Update any custom PIREP fields
|
||||
*
|
||||
* @param Flight $flight
|
||||
* @param array $field_values
|
||||
*/
|
||||
@@ -164,7 +172,7 @@ class FlightService extends Service
|
||||
'name' => $fv['name'],
|
||||
],
|
||||
[
|
||||
'value' => $fv['value']
|
||||
'value' => $fv['value'],
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -172,7 +180,9 @@ class FlightService extends Service
|
||||
|
||||
/**
|
||||
* Return all of the navaid points as a collection
|
||||
*
|
||||
* @param Flight $flight
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getRoute(Flight $flight)
|
||||
@@ -198,30 +208,33 @@ class FlightService extends Service
|
||||
|
||||
/**
|
||||
* Allow a user to bid on a flight. Check settings and all that good stuff
|
||||
*
|
||||
* @param Flight $flight
|
||||
* @param User $user
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \App\Exceptions\BidExists
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function addBid(Flight $flight, User $user)
|
||||
{
|
||||
# Get all of the bids for this user. See if they're allowed to have multiple
|
||||
# bids
|
||||
// Get all of the bids for this user. See if they're allowed to have multiple
|
||||
// bids
|
||||
$bids = Bid::where('user_id', $user->id)->get();
|
||||
if ($bids->count() > 0 && setting('bids.allow_multiple_bids') === false) {
|
||||
throw new BidExists('User "'.$user->ident.'" already has bids, skipping');
|
||||
}
|
||||
|
||||
# Get all of the bids for this flight
|
||||
// Get all of the bids for this flight
|
||||
$bids = Bid::where('flight_id', $flight->id)->get();
|
||||
if ($bids->count() > 0) {
|
||||
# Does the flight have a bid set?
|
||||
// Does the flight have a bid set?
|
||||
if ($flight->has_bid === false) {
|
||||
$flight->has_bid = true;
|
||||
$flight->save();
|
||||
}
|
||||
|
||||
# Check all the bids for one of this user
|
||||
// Check all the bids for one of this user
|
||||
foreach ($bids as $bid) {
|
||||
if ($bid->user_id === $user->id) {
|
||||
Log::info('Bid exists, user='.$user->ident.', flight='.$flight->id);
|
||||
@@ -229,7 +242,7 @@ class FlightService extends Service
|
||||
}
|
||||
}
|
||||
|
||||
# Check if the flight should be blocked off
|
||||
// Check if the flight should be blocked off
|
||||
if (setting('bids.disable_flight_on_bid') === true) {
|
||||
throw new BidExists('Flight "'.$flight->ident.'" already has a bid, skipping');
|
||||
}
|
||||
@@ -256,6 +269,7 @@ class FlightService extends Service
|
||||
|
||||
/**
|
||||
* Remove a bid from a given flight
|
||||
*
|
||||
* @param Flight $flight
|
||||
* @param User $user
|
||||
*/
|
||||
@@ -263,14 +277,14 @@ class FlightService extends Service
|
||||
{
|
||||
$bids = Bid::where([
|
||||
'flight_id' => $flight->id,
|
||||
'user_id' => $user->id
|
||||
'user_id' => $user->id,
|
||||
])->get();
|
||||
|
||||
foreach ($bids as $bid) {
|
||||
$bid->forceDelete();
|
||||
}
|
||||
|
||||
# Only flip the flag if there are no bids left for this flight
|
||||
// Only flip the flag if there are no bids left for this flight
|
||||
$bids = Bid::where('flight_id', $flight->id)->get();
|
||||
if ($bids->count() === 0) {
|
||||
$flight->has_bid = false;
|
||||
|
||||
Reference in New Issue
Block a user