Laravel 9 Update (#1413)
Update to Laravel 9 and PHP 8+ Co-authored-by: B.Fatih KOZ <fatih.koz@gmail.com>
This commit is contained in:
@@ -9,7 +9,7 @@ use App\Repositories\PirepRepository;
|
||||
|
||||
class AircraftService extends Service
|
||||
{
|
||||
private $pirepRepo;
|
||||
private PirepRepository $pirepRepo;
|
||||
|
||||
public function __construct(PirepRepository $pirepRepo)
|
||||
{
|
||||
|
||||
@@ -11,10 +11,10 @@ use App\Repositories\SubfleetRepository;
|
||||
|
||||
class AirlineService extends Service
|
||||
{
|
||||
private $airlineRepo;
|
||||
private $flightRepo;
|
||||
private $pirepRepo;
|
||||
private $subfleetRepo;
|
||||
private AirlineRepository $airlineRepo;
|
||||
private FlightRepository $flightRepo;
|
||||
private PirepRepository $pirepRepo;
|
||||
private SubfleetRepository $subfleetRepo;
|
||||
|
||||
public function __construct(
|
||||
AirlineRepository $airlineRepo,
|
||||
@@ -33,6 +33,8 @@ class AirlineService extends Service
|
||||
*
|
||||
* @param array $attr
|
||||
*
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
*
|
||||
* @return \App\Models\Airline
|
||||
*/
|
||||
public function createAirline(array $attr): Airline
|
||||
|
||||
@@ -9,7 +9,7 @@ use VaCentral\Exceptions\HttpException;
|
||||
|
||||
class VaCentralLookup extends AirportLookup
|
||||
{
|
||||
private $client;
|
||||
private IVaCentral $client;
|
||||
|
||||
public function __construct(IVaCentral $client)
|
||||
{
|
||||
|
||||
@@ -18,9 +18,9 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName;
|
||||
|
||||
class AirportService extends Service
|
||||
{
|
||||
private $airportRepo;
|
||||
private $lookupProvider;
|
||||
private $metarProvider;
|
||||
private AirportRepository $airportRepo;
|
||||
private AirportLookup $lookupProvider;
|
||||
private MetarProvider $metarProvider;
|
||||
|
||||
public function __construct(
|
||||
AirportLookup $lookupProvider,
|
||||
@@ -39,17 +39,19 @@ class AirportService extends Service
|
||||
*
|
||||
* @return Metar|null
|
||||
*/
|
||||
public function getMetar($icao)
|
||||
public function getMetar($icao): ?Metar
|
||||
{
|
||||
$icao = trim($icao);
|
||||
if ($icao === '') {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$raw_metar = $this->metarProvider->metar($icao);
|
||||
if ($raw_metar && $raw_metar !== '') {
|
||||
return new Metar($raw_metar);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,17 +61,19 @@ class AirportService extends Service
|
||||
*
|
||||
* @return Metar|null
|
||||
*/
|
||||
public function getTaf($icao)
|
||||
public function getTaf($icao): ?Metar
|
||||
{
|
||||
$icao = trim($icao);
|
||||
if ($icao === '') {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$raw_taf = $this->metarProvider->taf($icao);
|
||||
if ($raw_taf && $raw_taf !== '') {
|
||||
return new Metar($raw_taf, true);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,15 +10,13 @@ use App\Models\Flight;
|
||||
use App\Models\Pirep;
|
||||
use App\Models\SimBrief;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class BidService extends Service
|
||||
{
|
||||
/** @var FareService */
|
||||
private $fareSvc;
|
||||
|
||||
/** @var FlightService */
|
||||
private $flightSvc;
|
||||
private FareService $fareSvc;
|
||||
private FlightService $flightSvc;
|
||||
|
||||
public function __construct(FareService $fareSvc, FlightService $flightSvc)
|
||||
{
|
||||
@@ -29,9 +27,10 @@ class BidService extends Service
|
||||
/**
|
||||
* Get a specific bid for a user
|
||||
*
|
||||
* @param $bid_id
|
||||
* @param User $user
|
||||
* @param $bid_id
|
||||
*
|
||||
* @return \App\Models\Bid|\Illuminate\Database\Eloquent\Model|object|null
|
||||
* @return Bid|null
|
||||
*/
|
||||
public function getBid(User $user, $bid_id): ?Bid
|
||||
{
|
||||
@@ -67,9 +66,9 @@ class BidService extends Service
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
*
|
||||
* @return mixed
|
||||
* @return Bid[]
|
||||
*/
|
||||
public function findBidsForUser(User $user)
|
||||
public function findBidsForUser(User $user): Collection|array|null
|
||||
{
|
||||
$with = [
|
||||
'flight',
|
||||
|
||||
@@ -12,7 +12,7 @@ use Symfony\Component\Process\PhpExecutableFinder;
|
||||
|
||||
class CronService extends Service
|
||||
{
|
||||
private $kvpRepo;
|
||||
private KvpRepository $kvpRepo;
|
||||
|
||||
public function __construct(
|
||||
KvpRepository $kvpRepo
|
||||
|
||||
@@ -58,7 +58,8 @@ class ExportService extends Service
|
||||
|
||||
// Write the rest of the rows
|
||||
foreach ($collection as $row) {
|
||||
$writer->insertOne($exporter->export($row));
|
||||
$ins = $exporter->export($row);
|
||||
$writer->insertOne($ins);
|
||||
}
|
||||
|
||||
return $path;
|
||||
|
||||
@@ -27,10 +27,10 @@ use Illuminate\Support\Facades\Log;
|
||||
|
||||
class PirepFinanceService extends Service
|
||||
{
|
||||
private $expenseRepo;
|
||||
private $fareSvc;
|
||||
private $financeSvc;
|
||||
private $journalRepo;
|
||||
private ExpenseRepository $expenseRepo;
|
||||
private FareService $fareSvc;
|
||||
private FinanceService $financeSvc;
|
||||
private JournalRepository $journalRepo;
|
||||
|
||||
/**
|
||||
* FinanceService constructor.
|
||||
@@ -240,18 +240,18 @@ class PirepFinanceService extends Service
|
||||
if ($prev_flight) {
|
||||
// If there is a pirep use its values to calculate the remaining fuel
|
||||
// and calculate the uplifted fuel amount for this pirep
|
||||
$fuel_amount = $pirep->block_fuel - ($prev_flight->block_fuel - $prev_flight->fuel_used);
|
||||
$fuel_amount = $pirep->block_fuel->internal() - ($prev_flight->block_fuel->internal() - $prev_flight->fuel_used->internal());
|
||||
// Aircraft has more than enough fuel in its tanks, no uplift necessary
|
||||
if ($fuel_amount < 0) {
|
||||
$fuel_amount = 0;
|
||||
}
|
||||
} else {
|
||||
// No pirep found for aircraft, debit full block fuel
|
||||
$fuel_amount = $pirep->block_fuel;
|
||||
$fuel_amount = $pirep->block_fuel->internal();
|
||||
}
|
||||
} else {
|
||||
// Setting is false, switch back to basic calculation
|
||||
$fuel_amount = $pirep->fuel_used;
|
||||
$fuel_amount = $pirep->fuel_used->internal();
|
||||
}
|
||||
|
||||
$debit = Money::createFromAmount($fuel_amount * $fuel_cost);
|
||||
|
||||
@@ -7,7 +7,6 @@ use App\Models\Airline;
|
||||
use App\Models\Enums\ExpenseType;
|
||||
use App\Models\Expense;
|
||||
use App\Models\JournalTransaction;
|
||||
use App\Repositories\JournalRepository;
|
||||
use App\Services\FinanceService;
|
||||
use App\Support\Money;
|
||||
use Carbon\Carbon;
|
||||
@@ -18,13 +17,11 @@ use Illuminate\Support\Facades\Log;
|
||||
*/
|
||||
class RecurringFinanceService extends Service
|
||||
{
|
||||
private $financeSvc;
|
||||
private $journalRepo;
|
||||
private FinanceService $financeSvc;
|
||||
|
||||
public function __construct(JournalRepository $journalRepo, FinanceService $financeSvc)
|
||||
public function __construct(FinanceService $financeSvc)
|
||||
{
|
||||
$this->financeSvc = $financeSvc;
|
||||
$this->journalRepo = $journalRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,8 +13,8 @@ use App\Support\Money;
|
||||
|
||||
class FinanceService extends Service
|
||||
{
|
||||
private $airlineRepo;
|
||||
private $journalRepo;
|
||||
private AirlineRepository $airlineRepo;
|
||||
private JournalRepository $journalRepo;
|
||||
|
||||
public function __construct(
|
||||
AirlineRepository $airlineRepo,
|
||||
|
||||
@@ -15,11 +15,11 @@ use App\Support\Units\Time;
|
||||
|
||||
class FlightService extends Service
|
||||
{
|
||||
private $airportSvc;
|
||||
private $fareSvc;
|
||||
private $flightRepo;
|
||||
private $navDataRepo;
|
||||
private $userSvc;
|
||||
private AirportService $airportSvc;
|
||||
private FareService $fareSvc;
|
||||
private FlightRepository $flightRepo;
|
||||
private NavdataRepository $navDataRepo;
|
||||
private UserService $userSvc;
|
||||
|
||||
/**
|
||||
* FlightService constructor.
|
||||
|
||||
@@ -18,8 +18,8 @@ use League\Geotools\Geotools;
|
||||
|
||||
class GeoService extends Service
|
||||
{
|
||||
private $acarsRepo;
|
||||
private $navRepo;
|
||||
private AcarsRepository $acarsRepo;
|
||||
private NavdataRepository $navRepo;
|
||||
|
||||
/**
|
||||
* GeoService constructor.
|
||||
|
||||
@@ -31,12 +31,13 @@ class AircraftExporter extends ImportExport
|
||||
{
|
||||
$ret = [];
|
||||
foreach (self::$columns as $column) {
|
||||
$ret[$column] = $aircraft->{$column};
|
||||
if ($column === 'subfleet') {
|
||||
$ret['subfleet'] = $aircraft->subfleet->type;
|
||||
} else {
|
||||
$ret[$column] = $aircraft->{$column};
|
||||
}
|
||||
}
|
||||
|
||||
// Modify special fields
|
||||
$ret['subfleet'] = $aircraft->subfleet->type;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,17 +35,13 @@ class ExpenseExporter extends ImportExport
|
||||
$ret = [];
|
||||
|
||||
foreach (self::$columns as $col) {
|
||||
$ret[$col] = $expense->{$col};
|
||||
}
|
||||
|
||||
// Special fields
|
||||
|
||||
if ($ret['airline']) {
|
||||
$ret['airline'] = $expense->airline->icao;
|
||||
}
|
||||
|
||||
if ($ret['flight_type']) {
|
||||
$ret['flight_type'] = $ret['flight_type'][0];
|
||||
if ($col === 'airline') {
|
||||
$ret['airline'] = optional($expense->airline)->icao;
|
||||
} elseif ($col === 'flight_type') {
|
||||
$ret['flight_type'] = implode(',', $expense->flight_type);
|
||||
} else {
|
||||
$ret[$col] = $expense->{$col};
|
||||
}
|
||||
}
|
||||
|
||||
// For the different expense types, instead of exporting
|
||||
|
||||
@@ -36,7 +36,7 @@ class FlightExporter extends ImportExport
|
||||
}
|
||||
|
||||
// Modify special fields
|
||||
$ret['airline'] = $ret['airline']->icao;
|
||||
$ret['airline'] = $flight->airline->icao;
|
||||
$ret['dpt_airport'] = $flight->dpt_airport_id;
|
||||
$ret['arr_airport'] = $flight->arr_airport_id;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ use League\Csv\Reader;
|
||||
|
||||
class ImportService extends Service
|
||||
{
|
||||
protected $flightRepo;
|
||||
protected FlightRepository $flightRepo;
|
||||
|
||||
/**
|
||||
* ImporterService constructor.
|
||||
|
||||
@@ -23,17 +23,17 @@ use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ImporterService extends Service
|
||||
{
|
||||
private $CREDENTIALS_KEY = 'legacy.importer.db';
|
||||
private string $CREDENTIALS_KEY = 'legacy.importer.db';
|
||||
|
||||
/**
|
||||
* @var KvpRepository
|
||||
*/
|
||||
private $kvpRepo;
|
||||
private mixed $kvpRepo;
|
||||
|
||||
/**
|
||||
* The list of importers, in proper order
|
||||
*/
|
||||
private $importList = [
|
||||
private array $importList = [
|
||||
ClearDatabase::class,
|
||||
RankImport::class,
|
||||
GroupImporter::class,
|
||||
|
||||
@@ -15,7 +15,7 @@ use Symfony\Component\HttpFoundation\File\Exception\FileException;
|
||||
|
||||
class ConfigService extends Service
|
||||
{
|
||||
protected static $defaultValues = [
|
||||
protected static array $defaultValues = [
|
||||
'APP_ENV' => 'production',
|
||||
'APP_KEY' => '',
|
||||
'APP_DEBUG' => false,
|
||||
@@ -194,10 +194,10 @@ class ConfigService extends Service
|
||||
// If it's mariadb, enable the emulation for prepared statements
|
||||
// seems to be throwing a problem on 000webhost
|
||||
// https://github.com/nabeelio/phpvms/issues/132
|
||||
if (strpos($version, 'mariadb') !== false) {
|
||||
/*if (strpos($version, 'mariadb') !== false) {
|
||||
Log::info('Detected MariaDB, setting DB_EMULATE_PREPARES to true');
|
||||
$opts['DB_EMULATE_PREPARES'] = true;
|
||||
}
|
||||
}*/
|
||||
|
||||
return $opts;
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ use Illuminate\Support\Facades\Log;
|
||||
|
||||
class InstallerService extends Service
|
||||
{
|
||||
private $migrationSvc;
|
||||
private $seederSvc;
|
||||
private MigrationService $migrationSvc;
|
||||
private SeederService $seederSvc;
|
||||
|
||||
/**
|
||||
* @param $migrationSvc
|
||||
* @param $seederSvc
|
||||
* @param MigrationService $migrationSvc
|
||||
* @param SeederService $seederSvc
|
||||
*/
|
||||
public function __construct(MigrationService $migrationSvc, SeederService $seederSvc)
|
||||
{
|
||||
|
||||
@@ -15,10 +15,10 @@ use function trim;
|
||||
|
||||
class SeederService extends Service
|
||||
{
|
||||
private $databaseSvc;
|
||||
private DatabaseService $databaseSvc;
|
||||
|
||||
private $counters = [];
|
||||
private $offsets = [];
|
||||
private array $counters = [];
|
||||
private array $offsets = [];
|
||||
|
||||
// Map an environment to a seeder directory, if we want to share
|
||||
public static $seed_mapper = [
|
||||
|
||||
@@ -19,8 +19,14 @@ class AviationWeather extends Metar
|
||||
private const TAF_URL =
|
||||
'https://www.aviationweather.gov/adds/dataserver_current/httpparam?dataSource=tafs&requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&stationString=';
|
||||
|
||||
private $httpClient;
|
||||
/**
|
||||
* @var HttpClient
|
||||
*/
|
||||
private HttpClient $httpClient;
|
||||
|
||||
/**
|
||||
* @param HttpClient $httpClient
|
||||
*/
|
||||
public function __construct(HttpClient $httpClient)
|
||||
{
|
||||
$this->httpClient = $httpClient;
|
||||
|
||||
@@ -22,12 +22,12 @@ use PharData;
|
||||
|
||||
class ModuleService extends Service
|
||||
{
|
||||
protected static $adminLinks = [];
|
||||
protected static array $adminLinks = [];
|
||||
|
||||
/**
|
||||
* @var array 0 == logged out, 1 == logged in
|
||||
*/
|
||||
protected static $frontendLinks = [
|
||||
protected static array $frontendLinks = [
|
||||
0 => [],
|
||||
1 => [],
|
||||
];
|
||||
@@ -40,7 +40,7 @@ class ModuleService extends Service
|
||||
* @param string $icon
|
||||
* @param bool $logged_in
|
||||
*/
|
||||
public function addFrontendLink(string $title, string $url, string $icon = 'pe-7s-users', $logged_in = true)
|
||||
public function addFrontendLink(string $title, string $url, string $icon = 'pe-7s-users', bool $logged_in = true)
|
||||
{
|
||||
self::$frontendLinks[$logged_in][] = [
|
||||
'title' => $title,
|
||||
@@ -56,7 +56,7 @@ class ModuleService extends Service
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFrontendLinks($logged_in): array
|
||||
public function getFrontendLinks(mixed $logged_in): array
|
||||
{
|
||||
return self::$frontendLinks[$logged_in];
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use App\Repositories\NewsRepository;
|
||||
|
||||
class NewsService extends Service
|
||||
{
|
||||
private $newsRepo;
|
||||
private NewsRepository $newsRepo;
|
||||
|
||||
public function __construct(NewsRepository $newsRepo)
|
||||
{
|
||||
|
||||
@@ -35,20 +35,21 @@ use App\Models\User;
|
||||
use App\Repositories\AircraftRepository;
|
||||
use App\Repositories\AirportRepository;
|
||||
use App\Repositories\PirepRepository;
|
||||
use App\Support\Units\Fuel;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class PirepService extends Service
|
||||
{
|
||||
private $aircraftRepo;
|
||||
private $airportRepo;
|
||||
private $airportSvc;
|
||||
private $fareSvc;
|
||||
private $geoSvc;
|
||||
private $pirepRepo;
|
||||
private $simBriefSvc;
|
||||
private $userSvc;
|
||||
private AircraftRepository $aircraftRepo;
|
||||
private AirportRepository $airportRepo;
|
||||
private AirportService $airportSvc;
|
||||
private FareService $fareSvc;
|
||||
private GeoService $geoSvc;
|
||||
private PirepRepository $pirepRepo;
|
||||
private SimBriefService $simBriefSvc;
|
||||
private UserService $userSvc;
|
||||
|
||||
/**
|
||||
* @param AirportRepository $airportRepo
|
||||
@@ -664,11 +665,14 @@ class PirepService extends Service
|
||||
|
||||
Log::info('PIREP '.$pirep->id.' state change to ACCEPTED');
|
||||
|
||||
$fuel_remain = $pirep->block_fuel->internal() - $pirep->fuel_used->internal();
|
||||
$fuel_on_board = Fuel::make($fuel_remain, config('phpvms.internal_units.fuel'));
|
||||
|
||||
// Update the aircraft
|
||||
$pirep->aircraft->flight_time = $pirep->aircraft->flight_time + $pirep->flight_time;
|
||||
$pirep->aircraft->airport_id = $pirep->arr_airport_id;
|
||||
$pirep->aircraft->landing_time = $pirep->updated_at;
|
||||
$pirep->aircraft->fuel_onboard = $pirep->block_fuel - $pirep->fuel_used;
|
||||
$pirep->aircraft->fuel_onboard = $fuel_on_board;
|
||||
$pirep->aircraft->save();
|
||||
|
||||
$pirep->refresh();
|
||||
|
||||
@@ -8,7 +8,7 @@ use App\Repositories\RoleRepository;
|
||||
|
||||
class RoleService extends Service
|
||||
{
|
||||
private $roleRepo;
|
||||
private RoleRepository $roleRepo;
|
||||
|
||||
public function __construct(RoleRepository $roleRepo)
|
||||
{
|
||||
|
||||
@@ -15,8 +15,11 @@ use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SimBriefService extends Service
|
||||
{
|
||||
private $httpClient;
|
||||
private GuzzleClient $httpClient;
|
||||
|
||||
/**
|
||||
* @param GuzzleClient $httpClient
|
||||
*/
|
||||
public function __construct(GuzzleClient $httpClient)
|
||||
{
|
||||
$this->httpClient = $httpClient;
|
||||
@@ -26,13 +29,13 @@ class SimBriefService extends Service
|
||||
* Check to see if the OFP exists server-side. If it does, download it and
|
||||
* cache it immediately
|
||||
*
|
||||
* @param string $user_id User who generated this
|
||||
* @param string $ofp_id The SimBrief OFP ID
|
||||
* @param string $flight_id The flight ID
|
||||
* @param string $ac_id The aircraft ID
|
||||
* @param array $fares Full list of fares for the flight
|
||||
* @param string $sb_userid User's Simbrief ID (Used for Update)
|
||||
* @param string $sb_static_id Static ID for the generated OFP (Used for Update)
|
||||
* @param string $user_id User who generated this
|
||||
* @param string $ofp_id The SimBrief OFP ID
|
||||
* @param string $flight_id The flight ID
|
||||
* @param string $ac_id The aircraft ID
|
||||
* @param array $fares Full list of fares for the flight
|
||||
* @param string|null $sb_user_id
|
||||
* @param string|null $sb_static_id Static ID for the generated OFP (Used for Update)
|
||||
*
|
||||
* @return SimBrief|null
|
||||
*/
|
||||
|
||||
@@ -32,11 +32,11 @@ use function is_array;
|
||||
|
||||
class UserService extends Service
|
||||
{
|
||||
private $aircraftRepo;
|
||||
private $airlineRepo;
|
||||
private $fareSvc;
|
||||
private $subfleetRepo;
|
||||
private $userRepo;
|
||||
private AircraftRepository $aircraftRepo;
|
||||
private AirlineRepository $airlineRepo;
|
||||
private FareService $fareSvc;
|
||||
private SubfleetRepository $subfleetRepo;
|
||||
private UserRepository $userRepo;
|
||||
|
||||
/**
|
||||
* @param AircraftRepository $aircraftRepo
|
||||
|
||||
@@ -12,8 +12,8 @@ use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class VersionService extends Service
|
||||
{
|
||||
private $httpClient;
|
||||
private $kvpRepo;
|
||||
private HttpClient $httpClient;
|
||||
private KvpRepository $kvpRepo;
|
||||
|
||||
public function __construct(
|
||||
HttpClient $httpClient,
|
||||
|
||||
Reference in New Issue
Block a user