Merge pull request #261 from nabeelio/analysis-8Kyry9

Apply fixes from StyleCI
This commit is contained in:
Nabeel Shahzad
2018-08-26 12:19:08 -05:00
committed by GitHub
407 changed files with 4032 additions and 3286 deletions

View File

@@ -7,13 +7,13 @@ use App\Interfaces\Award;
/**
* Simple example of an awards class, where you can apply an award when a user
* has 100 flights. All award classes need to extend the AwardInterface
* @package App\Awards
*/
class PilotFlightAwards extends Award
{
/**
* Set the name of this award class to make it easier to see when
* assigning to a specific award
*
* @var string
*/
public $name = 'Pilot Flights';
@@ -22,6 +22,7 @@ class PilotFlightAwards extends Award
* The description to show under the parameters field, so the admin knows
* what the parameter actually controls. You can leave this blank if there
* isn't a parameter.
*
* @var string
*/
public $param_description = 'The number of flights at which to give this award';
@@ -33,7 +34,9 @@ class PilotFlightAwards extends Award
* If no parameter is passed in, just default it to 100. You should check if there
* is a parameter or not. You can call it whatever you want, since that would make
* sense with the $param_description.
*
* @param int|null $number_of_flights The parameters passed in from the UI
*
* @return bool
*/
public function check($number_of_flights = null): bool

View File

@@ -7,30 +7,22 @@ use Illuminate\Contracts\Foundation\Application;
/**
* Class LoadConfiguration
* @package App\Bootstrap
*
* I'm overriding this to take advantage of the configuration caching
* and not needing to read the files from disk every time.
*
* Hopefully it won't affect anything within core framework but this
* should be ok. Will just have to be cognizant of any changes to the
* LoadConfiguration parent class, or if the Kernel changes the boot
* order -NS
*/
class LoadConfiguration extends \Illuminate\Foundation\Bootstrap\LoadConfiguration
{
/**
* Load the configuration items from all of the files.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @param \Illuminate\Contracts\Config\Repository $repository
* @param \Illuminate\Contracts\Foundation\Application $app
* @param \Illuminate\Contracts\Config\Repository $repository
*
* @throws \Exception
*/
protected function loadConfigurationFiles(Application $app, RepositoryContract $repository)
{
parent::loadConfigurationFiles($app, $repository);
/**
/*
* Read in the base config, only if it exists
*/
if (file_exists($app->basePath().'/config.php')) {

View File

@@ -7,7 +7,6 @@ use Symfony\Component\Process\Process;
/**
* Class BaseCommand
* @package App\Console
*/
abstract class Command extends \Illuminate\Console\Command
{
@@ -52,7 +51,9 @@ abstract class Command extends \Illuminate\Console\Command
/**
* Streaming file reader
*
* @param $filename
*
* @return \Generator
*/
public function readFile($filename): ?\Generator
@@ -71,16 +72,19 @@ abstract class Command extends \Illuminate\Console\Command
}
/**
* @param $cmd
* @param bool $return
* @return string
* @param $cmd
* @param bool $return
* @param mixed $verbose
*
* @throws \Symfony\Component\Process\Exception\RuntimeException
* @throws \Symfony\Component\Process\Exception\LogicException
*
* @return string
*/
public function runCommand($cmd, $return = false, $verbose = true): string
{
if (\is_array($cmd)) {
$cmd = join(' ', $cmd);
$cmd = implode(' ', $cmd);
}
if ($verbose) {

View File

@@ -9,7 +9,6 @@ use Illuminate\Database\Eloquent\Collection;
/**
* Class AcarsReplay
* @package App\Console\Commands
*/
class AcarsReplay extends Command
{
@@ -18,12 +17,14 @@ class AcarsReplay extends Command
/**
* API Key to post as
*
* @var string
*/
protected $apiKey = 'testadminapikey';
/**
* For automatic updates, how many seconds to sleep between updates
*
* @var int
*/
protected $sleepTime = 10;
@@ -50,19 +51,22 @@ class AcarsReplay extends Command
'base_uri' => config('app.url'),
'headers' => [
'Authorization' => $this->apiKey,
]
],
]);
}
/**
* Make a request to start a PIREP
*
* @param \stdClass $flight
* @return string
*
* @throws \RuntimeException
*
* @return string
*/
protected function startPirep($flight): string
{
# convert the planned flight time to be completely in minutes
// convert the planned flight time to be completely in minutes
$pft = Utils::hoursToMinutes(
$flight->planned_hrsenroute,
$flight->planned_minenroute
@@ -80,7 +84,7 @@ class AcarsReplay extends Command
'level' => $flight->planned_altitude,
'planned_flight_time' => $pft,
'route' => $flight->planned_route,
]
],
]);
$body = \json_decode($response->getBody()->getContents());
@@ -90,14 +94,17 @@ class AcarsReplay extends Command
/**
* Mark the PIREP as filed
*
* @param $pirep_id
* @return mixed
*
* @throws \RuntimeException
*
* @return mixed
*/
protected function filePirep($pirep_id)
{
$response = $this->httpClient->post('/api/pireps/'.$pirep_id.'/file', [
'json' => []
'json' => [],
]);
$body = \json_decode($response->getBody()->getContents());
@@ -108,8 +115,10 @@ class AcarsReplay extends Command
/**
* @param $pirep_id
* @param $data
* @return array
*
* @throws \RuntimeException
*
* @return array
*/
protected function postUpdate($pirep_id, $data)
{
@@ -127,15 +136,15 @@ class AcarsReplay extends Command
$upd = [
'positions' => [
$position
]
$position,
],
];
$this->info("Update: $data->callsign, $position[lat] x $position[lon] \t\t"
."hdg: $position[heading]\t\talt: $position[altitude]\t\tgs: $position[gs]");
$response = $this->httpClient->post($uri, [
'json' => $upd
'json' => $upd,
]);
$body = \json_decode($response->getBody()->getContents());
@@ -146,13 +155,15 @@ class AcarsReplay extends Command
$position['lon'],
$position['heading'],
$position['altitude'],
$position['gs']
$position['gs'],
];
}
/**
* Parse this file and run the updates
*
* @param array $files
*
* @throws \RuntimeException
*/
protected function updatesFromFile(array $files)
@@ -168,20 +179,19 @@ class AcarsReplay extends Command
$contents = \json_decode($contents);
return collect($contents->updates);
} else {
$this->error($file.' not found, skipping');
return false;
}
$this->error($file.' not found, skipping');
return false;
})
# remove any of errored file entries
// remove any of errored file entries
->filter(function ($value, $key) {
return $value !== false;
});
$this->info('Starting playback');
/**
/*
* File the initial pirep to get a "preflight" status
*/
$flights->each(function ($updates, $idx) {
@@ -191,7 +201,7 @@ class AcarsReplay extends Command
$this->info('Prefiled '.$update->callsign.', ID: '.$pirep_id);
});
/**
/*
* Iterate through all of the flights, retrieving the updates
* from each individual flight. Remove the update. Continue through
* until there are no updates left, at which point we remove the flight
@@ -206,7 +216,7 @@ class AcarsReplay extends Command
$this->postUpdate($pirep_id, $update);
# we're done and don't put the "no-submit" option
// we're done and don't put the "no-submit" option
if ($updates->count() === 0 && !$this->option('no-submit')) {
$this->filePirep($pirep_id);
}
@@ -226,8 +236,10 @@ class AcarsReplay extends Command
/**
* Execute the console command.
* @return mixed
*
* @throws \RuntimeException
*
* @return mixed
*/
public function handle()
{

View File

@@ -7,7 +7,6 @@ use Artisan;
/**
* Class ComposerCommand
* @package App\Console\Commands
*/
class ComposerCommand extends Command
{
@@ -19,8 +18,7 @@ class ComposerCommand extends Command
*/
public function handle()
{
switch(trim($this->argument('cmd')))
{
switch (trim($this->argument('cmd'))) {
case 'post-update':
$this->postUpdate();
break;

View File

@@ -7,7 +7,6 @@ use Log;
/**
* Class CreateDatabase
* @package App\Console\Commands
*/
class CreateDatabase extends Command
{
@@ -26,7 +25,9 @@ class CreateDatabase extends Command
/**
* Create the mysql database
*
* @param $dbkey
*
* @return bool
*/
protected function create_mysql($dbkey)
@@ -52,6 +53,7 @@ class CreateDatabase extends Command
if ($this->option('reset') === true) {
$sql = "DROP DATABASE IF EXISTS `$name`";
try {
Log::info('Dropping database: '.$sql);
$conn->exec($sql);
@@ -74,6 +76,7 @@ class CreateDatabase extends Command
/**
* Create the sqlite database
*
* @param $dbkey
*/
protected function create_sqlite($dbkey)

View File

@@ -15,7 +15,6 @@ use Symfony\Component\Yaml\Yaml;
/**
* Class DevCommands
* @package App\Console\Commands
*/
class DevCommands extends Command
{
@@ -25,6 +24,7 @@ class DevCommands extends Command
/**
* DevCommands constructor.
*
* @param DatabaseService $dbSvc
*/
public function __construct(DatabaseService $dbSvc)
@@ -173,7 +173,7 @@ class DevCommands extends Command
}
$yaml[$table_name][] = $yaml_row;
++$count;
$count++;
}
$this->info('Exporting '.$count.' rows');
@@ -198,9 +198,8 @@ class DevCommands extends Command
$yml = Yaml::parse(file_get_contents($file));
foreach ($yml as $table => $rows) {
$this->info('Importing table ' . $table);
$this->info('Number of rows: ' . \count($rows));
$this->info('Importing table '.$table);
$this->info('Number of rows: '.\count($rows));
foreach ($rows as $row) {
try {

View File

@@ -7,7 +7,6 @@ use Modules\Installer\Services\ConfigService;
/**
* Create a fresh development install
* @package App\Console\Commands
*/
class DevInstall extends Command
{
@@ -24,6 +23,7 @@ class DevInstall extends Command
/**
* Run dev related commands
*
* @throws \Symfony\Component\HttpFoundation\File\Exception\FileException
*/
public function handle()
@@ -32,7 +32,7 @@ class DevInstall extends Command
$this->rewriteConfigs();
}
# Reload the configuration
// Reload the configuration
\App::boot();
$this->info('Recreating database');
@@ -45,13 +45,13 @@ class DevInstall extends Command
'--seed' => true,
]);
#
#
//
//
$this->info('Importing sample data');
foreach($this->yaml_imports as $yml) {
foreach ($this->yaml_imports as $yml) {
$this->call('phpvms:yaml-import', [
'files' => ['app/Database/seeds/' . $yml],
'files' => ['app/Database/seeds/'.$yml],
]);
}
@@ -60,6 +60,7 @@ class DevInstall extends Command
/**
* Rewrite the configuration files
*
* @throws \Symfony\Component\HttpFoundation\File\Exception\FileException
*/
protected function rewriteConfigs()
@@ -68,7 +69,7 @@ class DevInstall extends Command
$this->info('Removing the old config files');
# Remove the old files
// Remove the old files
$config_file = base_path('config.php');
if (file_exists($config_file)) {
unlink($config_file);

View File

@@ -1,7 +1,4 @@
<?php
/**
*
*/
namespace App\Console\Commands;
@@ -10,7 +7,6 @@ use App\Services\ImportService;
/**
* Class ImportCsv
* @package App\Console\Commands
*/
class ImportCsv extends Command
{
@@ -21,6 +17,7 @@ class ImportCsv extends Command
/**
* Import constructor.
*
* @param ImportService $importer
*/
public function __construct(ImportService $importer)
@@ -30,8 +27,9 @@ class ImportCsv extends Command
}
/**
* @return mixed|void
* @throws \Illuminate\Validation\ValidationException
*
* @return mixed|void
*/
public function handle()
{
@@ -48,7 +46,7 @@ class ImportCsv extends Command
$status = $this->importer->importSubfleets($file);
}
foreach($status['success'] as $line) {
foreach ($status['success'] as $line) {
$this->info($line);
}

View File

@@ -19,7 +19,7 @@ class ImportFromClassic extends Command
'name' => $this->argument('db_name'),
'user' => $this->argument('db_user'),
'pass' => $this->argument('db_pass'),
'table_prefix' => $this->argument('table_prefix')
'table_prefix' => $this->argument('table_prefix'),
];
$importerSvc = new \App\Console\Services\Importer($db_creds);

View File

@@ -8,7 +8,6 @@ use App\Models\Navdata;
/**
* Class NavdataImport
* @package App\Console\Commands
*/
class NavdataImport extends Command
{
@@ -16,8 +15,9 @@ class NavdataImport extends Command
protected $description = '';
/**
* @return void
* @throws \League\Geotools\Exception\InvalidArgumentException
*
* @return void
*/
public function handle()
{
@@ -31,8 +31,10 @@ class NavdataImport extends Command
/**
* Read and parse in the navaid file
* @return void
*
* @throws \League\Geotools\Exception\InvalidArgumentException
*
* @return void
*/
public function read_wp_nav_aid(): void
{
@@ -87,7 +89,7 @@ class NavdataImport extends Command
'class' => trim($line[60]),
];
# Map to the Navaid enum
// Map to the Navaid enum
switch ($navaid['type']) {
case 'ILS':
$navaid['type'] = NavaidType::LOC;
@@ -117,7 +119,7 @@ class NavdataImport extends Command
}*/
Navdata::updateOrCreate([
'id' => $navaid['id'], 'name' => $navaid['name']
'id' => $navaid['id'], 'name' => $navaid['name'],
], $navaid);
$imported++;
@@ -173,7 +175,7 @@ class NavdataImport extends Command
];
Navdata::updateOrCreate([
'id' => $navfix['id'], 'name' => $navfix['name']
'id' => $navfix['id'], 'name' => $navfix['name'],
], $navfix);
$imported++;

View File

@@ -7,7 +7,6 @@ use GuzzleHttp\Client;
/**
* Class TestApi
* @package App\Console\Commands
*/
class TestApi extends Command
{
@@ -24,7 +23,7 @@ class TestApi extends Command
'Authorization' => $this->argument('apikey'),
'Content-type' => 'application/json',
'X-API-Key' => $this->argument('apikey'),
]
],
]);
$result = $this->httpClient->get($this->argument('url'));

View File

@@ -7,7 +7,6 @@ use Symfony\Component\Yaml\Yaml;
/**
* Class Version
* @package App\Console\Commands
*/
class Version extends Command
{
@@ -15,13 +14,15 @@ class Version extends Command
/**
* Create the version number that gets written out
*
* @param mixed $cfg
*/
protected function createVersionNumber($cfg)
{
exec($cfg['git']['git-local'], $version);
$version = substr($version[0], 0, $cfg['build']['length']);
# prefix with the date in YYMMDD format
// prefix with the date in YYMMDD format
$date = date('ymd');
$version = $date.'-'.$version;
@@ -30,6 +31,7 @@ class Version extends Command
/**
* Run dev related commands
*
* @throws \Symfony\Component\Yaml\Exception\ParseException
*/
public function handle()
@@ -37,7 +39,7 @@ class Version extends Command
$version_file = config_path('version.yml');
$cfg = Yaml::parse(file_get_contents($version_file));
# Get the current build id
// Get the current build id
$build_number = $this->createVersionNumber($cfg);
$cfg['build']['number'] = $build_number;
@@ -48,13 +50,13 @@ class Version extends Command
file_put_contents($version_file, Yaml::dump($cfg, 4, 2));
}
# Only show the major.minor.patch version
// Only show the major.minor.patch version
if ($this->option('base-only')) {
$version = 'v'.$cfg['current']['major'].'.'
.$cfg['current']['minor'].'.'
.$cfg['current']['patch'];
}
print $version."\n";
echo $version."\n";
}
}

View File

@@ -9,7 +9,6 @@ use Symfony\Component\Yaml\Yaml;
/**
* Class YamlExport
* @package App\Console\Commands
*/
class YamlExport extends Command
{
@@ -18,6 +17,7 @@ class YamlExport extends Command
/**
* YamlExport constructor.
*
* @param DatabaseService $dbSvc
*/
public function __construct(DatabaseService $dbSvc)
@@ -47,6 +47,6 @@ class YamlExport extends Command
}
$yaml = Yaml::dump($export_tables, 4, 2);
print($yaml);
echo $yaml;
}
}

View File

@@ -7,7 +7,6 @@ use App\Services\DatabaseService;
/**
* Class YamlImport
* @package App\Console\Commands
*/
class YamlImport extends Command
{
@@ -17,6 +16,7 @@ class YamlImport extends Command
/**
* YamlImport constructor.
*
* @param DatabaseService $dbSvc
*/
public function __construct(DatabaseService $dbSvc)
@@ -27,6 +27,7 @@ class YamlImport extends Command
/**
* Run dev related commands
*
* @throws \Exception
*/
public function handle()

View File

@@ -8,7 +8,6 @@ use App\Events\CronHourly;
/**
* This just calls the CronHourly event, so all of the
* listeners, etc can just be called to run those tasks
* @package App\Console\Cron
*/
class Hourly extends Command
{
@@ -16,9 +15,6 @@ class Hourly extends Command
protected $description = 'Run the hourly cron tasks';
protected $schedule;
/**
*
*/
public function handle(): void
{
$this->redirectLoggingToStdout('cron');

View File

@@ -10,9 +10,6 @@ use App\Events\CronMonthly;
* listeners, etc can just be called to run those tasks
*
* The actual cron tasks are in app/Cron
*
* @package App\Console\Cron
*
*/
class Monthly extends Command
{
@@ -20,9 +17,6 @@ class Monthly extends Command
protected $description = 'Run the monthly cron tasks';
protected $schedule;
/**
*
*/
public function handle(): void
{
$this->redirectLoggingToStdout('cron');

View File

@@ -8,10 +8,8 @@ use App\Events\CronNightly;
/**
* This just calls the CronNightly event, so all of the
* listeners, etc can just be called to run those tasks
*
* The actual cron tasks are in app/Cron
*
* @package App\Console\Cron
* The actual cron tasks are in app/Cron
*/
class Nightly extends Command
{
@@ -19,9 +17,6 @@ class Nightly extends Command
protected $description = 'Run the nightly cron tasks';
protected $schedule;
/**
*
*/
public function handle(): void
{
$this->redirectLoggingToStdout('cron');

View File

@@ -10,8 +10,6 @@ use App\Events\CronWeekly;
* listeners, etc can just be called to run those tasks.
*
* The actual cron tasks are in app/Cron
*
* @package App\Console\Cron
*/
class Weekly extends Command
{
@@ -19,9 +17,6 @@ class Weekly extends Command
protected $description = 'Run the weekly cron tasks';
protected $schedule;
/**
*
*/
public function handle(): void
{
$this->redirectLoggingToStdout('cron');

View File

@@ -11,7 +11,6 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
/**
* Class Kernel
* @package App\Console
*/
class Kernel extends ConsoleKernel
{
@@ -27,7 +26,9 @@ class Kernel extends ConsoleKernel
/**
* Define the application's command schedule.
* @param \Illuminate\Console\Scheduling\Schedule $schedule
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
*
* @return void
*/
protected function schedule(Schedule $schedule): void
@@ -40,6 +41,7 @@ class Kernel extends ConsoleKernel
/**
* Register the Closure based commands for the application.
*
* @return void
*/
protected function commands(): void

View File

@@ -6,13 +6,13 @@ use Monolog\Handler\StreamHandler;
/**
* Just a simple custom logger that dumps to the console
* @package App\Console
*/
class Logger
{
public function __invoke(array $config)
{
$logger = new \Monolog\Logger('console');
try {
$logger->pushHandler(new StreamHandler('php://stdout'));
} catch (\Exception $e) {

View File

@@ -2,20 +2,20 @@
namespace App\Console\Services;
use PDOException;
use PDO;
/**
* Class Database
* @package App\Console\Services
*/
class Database
{
/**
* Create the base connection DSN, optionally include the DB name
*
* @param $host
* @param $port
* @param null $name
*
* @return string
*/
public function createDsn($host, $port, $name = null)
@@ -33,8 +33,10 @@ class Database
* @param $dsn
* @param $user
* @param $pass
* @return PDO
*
* @throws \PDOException
*
* @return PDO
*/
public function createPDO($dsn, $user, $pass)
{

View File

@@ -15,17 +15,16 @@ use App\Models\Rank;
use App\Models\Subfleet;
use App\Models\User;
use Carbon\Carbon;
use PDOException;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use PDO;
use PDOException;
use Symfony\Component\Console\Output\ConsoleOutput;
/**
* Class Importer
* TODO: Batch import
* @package App\Console\Services
*/
class Importer
{
@@ -36,6 +35,7 @@ class Importer
/**
* Hold the PDO connection to the old database
*
* @var
*/
private $conn;
@@ -47,6 +47,7 @@ class Importer
/**
* Hold the instance of the console logger
*
* @var
*/
private $log;
@@ -54,12 +55,12 @@ class Importer
/**
* CONSTANTS
*/
const BATCH_READ_ROWS = 300;
const SUBFLEET_NAME = 'Imported Aircraft';
const SUBFLEET_NAME = 'Imported Aircraft';
/**
* Importer constructor.
*
* @param $db_creds
*/
public function __construct($db_creds)
@@ -67,14 +68,14 @@ class Importer
// Setup the logger
$this->log = new ConsoleOutput();
# The db credentials
// The db credentials
$this->creds = array_merge([
'host' => '127.0.0.1',
'port' => 3306,
'name' => '',
'user' => '',
'pass' => '',
'table_prefix' => 'phpvms_'
'table_prefix' => 'phpvms_',
], $db_creds);
}
@@ -85,7 +86,7 @@ class Importer
{
$this->reconnect();
# Import all the different parts
// Import all the different parts
$this->importRanks();
$this->importAirlines();
$this->importAircraft();
@@ -95,7 +96,7 @@ class Importer
$this->importFlights();
$this->importPireps();
# Finish up
// Finish up
$this->findLastPireps();
$this->recalculateRanks();
}
@@ -108,7 +109,7 @@ class Importer
$dsn = 'mysql:'.implode(';', [
'host='.$this->creds['host'],
'port='.$this->creds['port'],
'dbname='.$this->creds['name']
'dbname='.$this->creds['name'],
]);
$this->info('Connection string: '.$dsn);
@@ -152,7 +153,9 @@ class Importer
/**
* Return the table name with the prefix
*
* @param $table
*
* @return string
*/
protected function tableName($table)
@@ -165,8 +168,8 @@ class Importer
}
/**
*
* @param \Illuminate\Database\Eloquent\Model $model
*
* @return bool
*/
protected function saveModel($model)
@@ -186,6 +189,7 @@ class Importer
/**
* Create a new mapping between an old ID and the new one
*
* @param $entity
* @param $old_id
* @param $new_id
@@ -201,8 +205,10 @@ class Importer
/**
* Return the ID for a mapping
*
* @param $entity
* @param $old_id
*
* @return bool
*/
protected function getMapping($entity, $old_id)
@@ -221,6 +227,7 @@ class Importer
/**
* @param $date
*
* @return Carbon
*/
protected function parseDate($date)
@@ -232,7 +239,9 @@ class Importer
/**
* Take a decimal duration and convert it to minutes
*
* @param $duration
*
* @return float|int
*/
protected function convertDuration($duration)
@@ -242,7 +251,7 @@ class Importer
} elseif (strpos($duration, ':')) {
$delim = ':';
} else {
# no delimiter, assume it's just a straight hour
// no delimiter, assume it's just a straight hour
return (int) $duration * 60;
}
@@ -255,6 +264,7 @@ class Importer
/**
* @param $table
*
* @return mixed
*/
protected function getTotalRows($table)
@@ -271,8 +281,10 @@ class Importer
/**
* Read all the rows in a table, but read them in a batched manner
*
* @param string $table The name of the table
* @param null $read_rows Number of rows to read
*
* @return \Generator
*/
protected function readRows($table, $read_rows = null)
@@ -318,6 +330,7 @@ class Importer
/**
* Return the subfleet
*
* @return mixed
*/
protected function getSubfleet()
@@ -332,10 +345,8 @@ class Importer
}
/**
*
* All the individual importers, done on a per-table basis
* Some tables get saved locally for tables that use FK refs
*
*/
/**
@@ -356,7 +367,7 @@ class Importer
$this->addMapping('ranks', $row->rank, $rank->id);
if ($rank->wasRecentlyCreated) {
++$count;
$count++;
}
}
@@ -382,7 +393,7 @@ class Importer
$this->addMapping('airlines', $row->code, $airline->id);
if ($airline->wasRecentlyCreated) {
++$count;
$count++;
}
}
@@ -406,13 +417,13 @@ class Importer
['name' => $row->fullname, 'registration' => $row->registration],
['icao' => $row->icao,
'subfleet_id' => $subfleet->id,
'active' => $row->enabled
'active' => $row->enabled,
]);
$this->addMapping('aircraft', $row->id, $aircraft->id);
if ($aircraft->wasRecentlyCreated) {
++$count;
$count++;
}
}
@@ -444,7 +455,7 @@ class Importer
);
if ($airport->wasRecentlyCreated) {
++$count;
$count++;
}
}
@@ -483,7 +494,7 @@ class Importer
$attrs
);
} catch (\Exception $e) {
#$this->error($e);
//$this->error($e);
}
$this->addMapping('flights', $row->id, $flight->id);
@@ -491,7 +502,7 @@ class Importer
// TODO: deserialize route_details into ACARS table
if ($flight->wasRecentlyCreated) {
++$count;
$count++;
}
}
@@ -513,7 +524,7 @@ class Importer
$aircraft_id = $this->getMapping('aircraft', $row->aircraft);
$attrs = [
#'id' => $pirep_id,
//'id' => $pirep_id,
'user_id' => $user_id,
'airline_id' => $airline_id,
'aircraft_id' => $aircraft_id,
@@ -527,24 +538,24 @@ class Importer
'updated_at' => $this->parseDate($row->modifieddate),
];
# Set the distance
// Set the distance
$distance = round($row->distance ?: 0, 2);
$attrs['distance'] = $distance;
$attrs['planned_distance'] = $distance;
# Set the flight time properly
// Set the flight time properly
$duration = $this->convertDuration($row->flighttime_stamp);
$attrs['flight_time'] = $duration;
$attrs['planned_flight_time'] = $duration;
# Set how it was filed
// Set how it was filed
if (strtoupper($row->source) === 'MANUAL') {
$attrs['source'] = PirepSource::MANUAL;
} else {
$attrs['source'] = PirepSource::ACARS;
}
# Set the flight type
// Set the flight type
$row->flighttype = strtoupper($row->flighttype);
if ($row->flighttype === 'P') {
$attrs['flight_type'] = FlightType::SCHED_PAX;
@@ -554,7 +565,7 @@ class Importer
$attrs['flight_type'] = FlightType::CHARTER_PAX_ONLY;
}
# Set the flight level of the PIREP is set
// Set the flight level of the PIREP is set
if (property_exists($row, 'flightlevel')) {
$attrs['level'] = $row->flightlevel;
} else {
@@ -568,18 +579,18 @@ class Importer
$source = strtoupper($row->source);
if ($source === 'SMARTCARS') {
# TODO: Parse smartcars log into the acars table
// TODO: Parse smartcars log into the acars table
} elseif ($source === 'KACARS') {
# TODO: Parse kACARS log into acars table
// TODO: Parse kACARS log into acars table
} elseif ($source === 'XACARS') {
# TODO: Parse XACARS log into acars table
// TODO: Parse XACARS log into acars table
}
# TODO: Add extra fields in as PIREP fields
// TODO: Add extra fields in as PIREP fields
$this->addMapping('pireps', $row->pirepid, $pirep->id);
if ($pirep->wasRecentlyCreated) {
++$count;
$count++;
}
}
@@ -592,7 +603,7 @@ class Importer
$count = 0;
foreach ($this->readRows('pilots', 50) as $row) {
# TODO: What to do about pilot ids
// TODO: What to do about pilot ids
$name = $row->firstname.' '.$row->lastname;
@@ -624,7 +635,7 @@ class Importer
$this->addMapping('users', $row->pilotid, $user->id);
if ($user->wasRecentlyCreated) {
++$count;
$count++;
}
}
@@ -648,7 +659,9 @@ class Importer
/**
* Get the user's new state from their original state
*
* @param $state
*
* @return int
*/
protected function getUserState($state)
@@ -662,21 +675,20 @@ class Importer
'ACTIVE' => 0,
'INACTIVE' => 1,
'BANNED' => 2,
'ON_LEAVE' => 3
'ON_LEAVE' => 3,
];
// Decide which state they will be in accordance with v7
if ($state === $phpvms_classic_states['ACTIVE']) {
return UserState::ACTIVE;
} elseif ($state === $phpvms_classic_states['INACTIVE']) {
# TODO: Make an inactive state?
// TODO: Make an inactive state?
return UserState::REJECTED;
} elseif ($state === $phpvms_classic_states['BANNED']) {
return UserState::SUSPENDED;
} elseif ($state === $phpvms_classic_states['ON_LEAVE']) {
return UserState::ON_LEAVE;
} else {
$this->error('Unknown status: '.$state);
}
$this->error('Unknown status: '.$state);
}
}

View File

@@ -9,18 +9,19 @@ use Carbon\Carbon;
/**
* Remove expired bids
* @package App\Listeners\Cron\Hourly
*/
class RemoveExpiredBids extends Listener
{
/**
* Remove expired bids
*
* @param CronHourly $event
*
* @throws \Exception
*/
public function handle(CronHourly $event): void
{
if(setting('bids.expire_time') === 0) {
if (setting('bids.expire_time') === 0) {
return;
}

View File

@@ -9,7 +9,6 @@ use App\Services\Finance\RecurringFinanceService;
/**
* Go through and apply any finances that are daily
* @package App\Listeners\Cron\Nightly
*/
class ApplyExpenses extends Listener
{
@@ -17,6 +16,7 @@ class ApplyExpenses extends Listener
/**
* ApplyExpenses constructor.
*
* @param RecurringFinanceService $financeSvc
*/
public function __construct(RecurringFinanceService $financeSvc)
@@ -26,7 +26,9 @@ class ApplyExpenses extends Listener
/**
* Apply all of the expenses for a month
*
* @param CronMonthly $event
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
* @throws \Prettus\Validator\Exceptions\ValidatorException

View File

@@ -9,7 +9,6 @@ use App\Services\Finance\RecurringFinanceService;
/**
* Go through and apply any finances that are daily
* @package App\Listeners\Cron\Nightly
*/
class ApplyExpenses extends Listener
{
@@ -17,6 +16,7 @@ class ApplyExpenses extends Listener
/**
* ApplyExpenses constructor.
*
* @param RecurringFinanceService $financeSvc
*/
public function __construct(RecurringFinanceService $financeSvc)
@@ -26,7 +26,9 @@ class ApplyExpenses extends Listener
/**
* Apply all of the expenses for a day
*
* @param CronNightly $event
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
* @throws \Prettus\Validator\Exceptions\ValidatorException

View File

@@ -11,7 +11,6 @@ use Carbon\Carbon;
/**
* Determine if any pilots should be set to ON LEAVE status
* @package App\Listeners\Cron\Nightly
*/
class PilotLeave extends Listener
{
@@ -27,13 +26,15 @@ class PilotLeave extends Listener
/**
* Set any users to being on leave after X days
*
* @param CronNightly $event
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*/
public function handle(CronNightly $event): void
{
if(setting('pilots.auto_leave_days') === 0) {
if (setting('pilots.auto_leave_days') === 0) {
return;
}
@@ -41,7 +42,7 @@ class PilotLeave extends Listener
$users = User::where('status', UserState::ACTIVE)
->whereDate('updated_at', '<', $date);
foreach($users as $user) {
foreach ($users as $user) {
Log::info('Setting user '.$user->ident.' to ON LEAVE status');
$this->userSvc->setStatusOnLeave($user);
}

View File

@@ -10,7 +10,6 @@ use Log;
/**
* This recalculates the balances on all of the journals
* @package App\Listeners\Cron
*/
class RecalculateBalances extends Listener
{
@@ -18,6 +17,7 @@ class RecalculateBalances extends Listener
/**
* Nightly constructor.
*
* @param JournalRepository $journalRepo
*/
public function __construct(JournalRepository $journalRepo)
@@ -27,7 +27,9 @@ class RecalculateBalances extends Listener
/**
* Recalculate all the balances for the different ledgers
*
* @param CronNightly $event
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*/

View File

@@ -5,19 +5,17 @@ namespace App\Cron\Nightly;
use App\Events\CronNightly;
use App\Interfaces\Listener;
use App\Models\Enums\UserState;
use App\Models\Journal;
use App\Repositories\UserRepository;
use App\Services\UserService;
use Log;
/**
* This recalculates the balances on all of the journals
* @package App\Listeners\Cron
*/
class RecalculateStats extends Listener
{
private $userRepo,
$userSvc;
private $userRepo;
private $userSvc;
public function __construct(UserRepository $userRepo, UserService $userService)
{
@@ -27,7 +25,9 @@ class RecalculateStats extends Listener
/**
* Recalculate the stats for active users
*
* @param CronNightly $event
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*/
@@ -36,7 +36,7 @@ class RecalculateStats extends Listener
Log::info('Recalculating balances');
$w = [
['state', '!=', UserState::REJECTED]
['state', '!=', UserState::REJECTED],
];
$users = $this->userRepo->findWhere($w, ['id', 'name', 'airline_id']);

View File

@@ -11,7 +11,6 @@ use Illuminate\Support\Facades\Log;
/**
* Figure out what flights need to be active for today
* @package App\Cron\Nightly
*/
class SetActiveFlights extends Listener
{
@@ -38,7 +37,7 @@ class SetActiveFlights extends Listener
/**
* @var Flight $flight
*/
foreach($flights as $flight) {
foreach ($flights as $flight) {
if (!$flight->active) {
continue;
}
@@ -73,8 +72,8 @@ class SetActiveFlights extends Listener
if ($today->gte($flight->start_date) && $today->lte($flight->end_date)) {
if ($flight->days !== null && $flight->days > 0) {
$visible = Days::isToday($flight->days);
if($flight->visible !== $visible) {
Log::info('Toggling flight '.$flight->ident.' to '.($visible?'shown':'hidden').'');
if ($flight->visible !== $visible) {
Log::info('Toggling flight '.$flight->ident.' to '.($visible ? 'shown' : 'hidden').'');
$flight->visible = $visible;
if ($visible === false) {

View File

@@ -4,11 +4,11 @@ use Faker\Generator as Faker;
$factory->define(App\Models\Aircraft::class, function (Faker $faker) {
return [
'id' => null,
'subfleet_id' => function () {
'id' => null,
'subfleet_id' => function () {
return factory(App\Models\Subfleet::class)->create()->id;
},
'airport_id' => function () {
'airport_id' => function () {
return factory(App\Models\Airport::class)->create()->id;
},
'iata' => $faker->unique()->text(5),

View File

@@ -3,23 +3,23 @@
use Faker\Generator as Faker;
use Hashids\Hashids;
/**
/*
* Add any number of airports. Don't really care if they're real or not
*/
$factory->define(App\Models\Airline::class, function (Faker $faker) {
return [
'id' => null,
'icao' => function (array $apt) use ($faker) {
'id' => null,
'icao' => function (array $apt) use ($faker) {
$hashids = new Hashids(microtime(), 5);
$mt = str_replace('.', '', microtime(true));
return $hashids->encode($mt);
},
'iata' => function (array $apt) {
'iata' => function (array $apt) {
return $apt['icao'];
},
'name' => $faker->sentence(3),
'country' => $faker->country,
'active' => 1
'active' => 1,
];
});

View File

@@ -2,7 +2,7 @@
use Faker\Generator as Faker;
/**
/*
* Add any number of airports. Don't really care if they're real or not
*/
$factory->define(App\Models\Airport::class, function (Faker $faker) {
@@ -17,10 +17,10 @@ $factory->define(App\Models\Airport::class, function (Faker $faker) {
return $string;
},
'icao' => function (array $apt) {
'icao' => function (array $apt) {
return $apt['id'];
},
'iata' => function (array $apt) {
'iata' => function (array $apt) {
return $apt['id'];
},
'name' => $faker->sentence(3),

View File

@@ -4,11 +4,11 @@ use Faker\Generator as Faker;
$factory->define(App\Models\Fare::class, function (Faker $faker) {
return [
'id' => null,
'code' => $faker->unique()->text(50),
'name' => $faker->text(50),
'price' => $faker->randomFloat(2, 100, 1000),
'cost' => function (array $fare) {
'id' => null,
'code' => $faker->unique()->text(50),
'name' => $faker->text(50),
'price' => $faker->randomFloat(2, 100, 1000),
'cost' => function (array $fare) {
return round($fare['price'] / 2);
},
'capacity' => $faker->randomFloat(0, 20, 500),

View File

@@ -2,13 +2,12 @@
/**
* Create flights
*/
use Faker\Generator as Faker;
$factory->define(App\Models\Flight::class, function (Faker $faker) {
return [
'id' => $faker->unique()->numberBetween(10, 10000000),
'airline_id' => function () {
'id' => $faker->unique()->numberBetween(10, 10000000),
'airline_id' => function () {
return factory(App\Models\Airline::class)->create()->id;
},
'flight_number' => $faker->unique()->numberBetween(10, 1000000),
@@ -23,20 +22,20 @@ $factory->define(App\Models\Flight::class, function (Faker $faker) {
'alt_airport_id' => function () {
return factory(App\Models\Airport::class)->create()->id;
},
'distance' => $faker->numberBetween(0, 3000),
'route' => null,
'level' => 0,
'dpt_time' => $faker->time(),
'arr_time' => $faker->time(),
'flight_time' => $faker->numberBetween(60, 360),
'has_bid' => false,
'active' => true,
'visible' => true,
'days' => 0,
'start_date' => null,
'end_date' => null,
'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
'updated_at' => function (array $flight) {
'distance' => $faker->numberBetween(0, 3000),
'route' => null,
'level' => 0,
'dpt_time' => $faker->time(),
'arr_time' => $faker->time(),
'flight_time' => $faker->numberBetween(60, 360),
'has_bid' => false,
'active' => true,
'visible' => true,
'days' => 0,
'start_date' => null,
'end_date' => null,
'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
'updated_at' => function (array $flight) {
return $flight['created_at'];
},
];

View File

@@ -8,10 +8,10 @@ $factory->define(App\Models\JournalTransactions::class, function (Faker $faker)
'journal_id' => function () {
return factory(App\Models\Journal::class)->create()->id;
},
'credit' => $faker->numberBetween(100, 10000),
'debit' => $faker->numberBetween(100, 10000),
'currency' => 'USD',
'memo' => $faker->sentence(6),
'post_date' => \Carbon\Carbon::now(),
'credit' => $faker->numberBetween(100, 10000),
'debit' => $faker->numberBetween(100, 10000),
'currency' => 'USD',
'memo' => $faker->sentence(6),
'post_date' => \Carbon\Carbon::now(),
];
});

View File

@@ -5,7 +5,7 @@ use Faker\Generator as Faker;
$factory->define(App\Models\News::class, function (Faker $faker) {
return [
'id' => null,
'user_id' => function() {
'user_id' => function () {
return factory(App\Models\User::class)->create()->id;
},
'subject' => $faker->text(),

View File

@@ -3,32 +3,32 @@
use Carbon\Carbon;
use Faker\Generator as Faker;
/**
/*
* Create a new PIREP
*/
$factory->define(App\Models\Pirep::class, function (Faker $faker) {
return [
'id' => $faker->unique()->numberBetween(10, 10000000),
'airline_id' => function () {
'id' => $faker->unique()->numberBetween(10, 10000000),
'airline_id' => function () {
return factory(App\Models\Airline::class)->create()->id;
},
'user_id' => function () {
'user_id' => function () {
return factory(App\Models\User::class)->create()->id;
},
'aircraft_id' => function () {
'aircraft_id' => function () {
return factory(App\Models\Aircraft::class)->create()->id;
},
'flight_number' => function (array $pirep) {
'flight_number' => function (array $pirep) {
return factory(App\Models\Flight::class)->create([
'airline_id' => $pirep['airline_id']
'airline_id' => $pirep['airline_id'],
])->flight_number;
},
'route_code' => null,
'route_leg' => null,
'dpt_airport_id' => function () {
'route_code' => null,
'route_leg' => null,
'dpt_airport_id' => function () {
return factory(App\Models\Airport::class)->create()->id;
},
'arr_airport_id' => function () {
'arr_airport_id' => function () {
return factory(App\Models\Airport::class)->create()->id;
},
'level' => $faker->numberBetween(20, 400),
@@ -43,15 +43,15 @@ $factory->define(App\Models\Pirep::class, function (Faker $faker) {
'block_off_time' => function (array $pirep) {
return $pirep['block_on_time']->subMinutes($pirep['flight_time']);
},
'route' => $faker->text(200),
'notes' => $faker->text(200),
'source' => $faker->randomElement([PirepSource::MANUAL, PirepSource::ACARS]),
'source_name' => 'Test Factory',
'state' => PirepState::PENDING,
'status' => PirepStatus::SCHEDULED,
'submitted_at' => Carbon::now('UTC')->toDateTimeString(),
'created_at' => Carbon::now('UTC')->toDateTimeString(),
'updated_at' => function (array $pirep) {
'route' => $faker->text(200),
'notes' => $faker->text(200),
'source' => $faker->randomElement([PirepSource::MANUAL, PirepSource::ACARS]),
'source_name' => 'Test Factory',
'state' => PirepState::PENDING,
'status' => PirepStatus::SCHEDULED,
'submitted_at' => Carbon::now('UTC')->toDateTimeString(),
'created_at' => Carbon::now('UTC')->toDateTimeString(),
'updated_at' => function (array $pirep) {
return $pirep['created_at'];
},
];

View File

@@ -4,8 +4,8 @@ use Faker\Generator as Faker;
$factory->define(App\Models\Subfleet::class, function (Faker $faker) {
return [
'id' => null,
'airline_id' => function () {
'id' => null,
'airline_id' => function () {
return factory(App\Models\Airline::class)->create()->id;
},
'name' => $faker->unique()->text(50),

View File

@@ -7,12 +7,12 @@ $factory->define(App\Models\User::class, function (Faker $faker) {
static $password;
return [
'id' => null,
'name' => $faker->name,
'email' => $faker->safeEmail,
'password' => $password ?: $password = Hash::make('secret'),
'api_key' => $faker->sha1,
'airline_id' => function () {
'id' => null,
'name' => $faker->name,
'email' => $faker->safeEmail,
'password' => $password ?: $password = Hash::make('secret'),
'api_key' => $faker->sha1,
'airline_id' => function () {
return factory(App\Models\Airline::class)->create()->id;
},
'rank_id' => 1,

View File

@@ -30,7 +30,7 @@ class CreateSettingsTable extends Migration
$table->timestamps();
});
/**
/*
* Initial default settings
*/
@@ -122,7 +122,7 @@ class CreateSettingsTable extends Migration
'description' => 'The units for temperature',
]);
/**
/*
* ACARS Settings
*/
@@ -151,7 +151,7 @@ class CreateSettingsTable extends Migration
'description' => 'Initial zoom level on the map',
]);
/**
/*
* BIDS
*/
@@ -179,7 +179,7 @@ class CreateSettingsTable extends Migration
'description' => 'Number of hours to expire bids after',
]);
/**
/*
* PIREPS
*/
@@ -223,7 +223,7 @@ class CreateSettingsTable extends Migration
'description' => 'When a PIREP is accepted, remove the bid, if it exists',
]);
/**
/*
* PILOTS
*/

View File

@@ -8,7 +8,7 @@ class RolesPermissionsTables extends Migration
/**
* Run the migrations.
*
* @return void
* @return void
*/
public function up()
{
@@ -67,7 +67,7 @@ class RolesPermissionsTables extends Migration
$table->primary(['permission_id', 'role_id']);
});
# create a default user/role
// create a default user/role
$roles = [
[
'id' => 1,
@@ -77,7 +77,7 @@ class RolesPermissionsTables extends Migration
[
'id' => 2,
'name' => 'user',
'display_name' => 'Pilot'
'display_name' => 'Pilot',
],
];
@@ -87,7 +87,7 @@ class RolesPermissionsTables extends Migration
/**
* Reverse the migrations.
*
* @return void
* @return void
*/
public function down()
{

View File

@@ -57,7 +57,7 @@ class CreateFlightTables extends Migration
$table->primary(['flight_id', 'fare_id']);
});
/**
/*
* Hold a master list of fields
*/
Schema::create('flight_fields', function (Blueprint $table) {
@@ -66,7 +66,7 @@ class CreateFlightTables extends Migration
$table->string('slug', 50)->nullable();
});
/**
/*
* The values for the actual fields
*/
Schema::create('flight_field_values', function (Blueprint $table) {

View File

@@ -39,7 +39,7 @@ class CreateRanksTable extends Migration
'hours' => 0,
'acars_base_pay_rate' => 50,
'manual_base_pay_rate' => 25,
]
],
];
$this->addData('ranks', $ranks);

View File

@@ -13,7 +13,7 @@ class CreateNavdataTables extends Migration
*/
public function up()
{
/**
/*
* See for defs, modify/update based on this
* https://github.com/skiselkov/openfmc/blob/master/airac.h
*/

View File

@@ -19,11 +19,11 @@ class CreateAwardsTable extends Migration
$table->text('description')->nullable();
$table->text('image_url')->nullable();
# ref fields are expenses tied to some model object
# EG, the airports has an internal expense for gate costs
// ref fields are expenses tied to some model object
// EG, the airports has an internal expense for gate costs
$table->string('ref_model')->nullable();
$table->text('ref_model_params')->nullable();
#$table->string('ref_model_id', 36)->nullable();
//$table->string('ref_model_id', 36)->nullable();
$table->timestamps();

View File

@@ -19,8 +19,8 @@ class CreateExpensesTable extends Migration
$table->boolean('multiplier')->nullable()->default(0);
$table->boolean('active')->nullable()->default(true);
# ref fields are expenses tied to some model object
# EG, the airports has an internal expense for gate costs
// ref fields are expenses tied to some model object
// EG, the airports has an internal expense for gate costs
$table->string('ref_model')->nullable();
$table->string('ref_model_id', 36)->nullable();

View File

@@ -1,13 +1,14 @@
<?php
use App\Interfaces\Migration;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFilesTable extends Migration
{
/**
* Create the files table. Acts as a morphable
*
* @return void
*/
public function up()

View File

@@ -6,6 +6,7 @@ class DatabaseSeeder extends Seeder
{
/**
* Map these other environments to a specific seed file
*
* @var array
*/
public static $seed_mapper = [
@@ -16,6 +17,7 @@ class DatabaseSeeder extends Seeder
/**
* Run the database seeds.
*
* @throws Exception
*/
public function run()

View File

@@ -7,7 +7,6 @@ use Illuminate\Queue\SerializesModels;
/**
* This event is dispatched when the hourly cron is run
* @package App\Events
*/
class CronHourly
{
@@ -18,6 +17,5 @@ class CronHourly
*/
public function __construct()
{
}
}

View File

@@ -8,7 +8,6 @@ use Illuminate\Queue\SerializesModels;
/**
* This event is dispatched when the monthly cron is run
* It happens after all of the default nightly tasks
* @package App\Events
*/
class CronMonthly
{
@@ -19,6 +18,5 @@ class CronMonthly
*/
public function __construct()
{
}
}

View File

@@ -8,7 +8,6 @@ use Illuminate\Queue\SerializesModels;
/**
* This event is dispatched when the daily cron is run
* It happens after all of the default nightly tasks
* @package App\Events
*/
class CronNightly
{
@@ -19,6 +18,5 @@ class CronNightly
*/
public function __construct()
{
}
}

View File

@@ -8,7 +8,6 @@ use Illuminate\Queue\SerializesModels;
/**
* This event is dispatched when the weekly cron is run
* It happens after all of the default nightly tasks
* @package App\Events
*/
class CronWeekly
{
@@ -19,6 +18,5 @@ class CronWeekly
*/
public function __construct()
{
}
}

View File

@@ -26,8 +26,6 @@ use Illuminate\Queue\SerializesModels;
* will filter out expenses that only apply to the current process
*
* The event will have a copy of the PIREP model, if it's applicable
*
* @package App\Events
*/
class Expenses
{

View File

@@ -9,7 +9,6 @@ use Illuminate\Queue\SerializesModels;
/**
* Class PirepAccepted
* @package App\Events
*/
class PirepAccepted
{
@@ -19,6 +18,7 @@ class PirepAccepted
/**
* PirepAccepted constructor.
*
* @param Pirep $pirep
*/
public function __construct(Pirep $pirep)

View File

@@ -9,7 +9,6 @@ use Illuminate\Queue\SerializesModels;
/**
* Class PirepRejected
* @package App\Events
*/
class PirepRejected
{
@@ -19,6 +18,7 @@ class PirepRejected
/**
* PirepRejected constructor.
*
* @param Pirep $pirep
*/
public function __construct(Pirep $pirep)

View File

@@ -9,7 +9,6 @@ use Illuminate\Queue\SerializesModels;
/**
* Class TestEvent
* @package App\Events
*/
class TestEvent
{
@@ -19,6 +18,7 @@ class TestEvent
/**
* Create a new event instance.
*
* @param User $user
*/
public function __construct(User $user)

View File

@@ -9,7 +9,6 @@ use Illuminate\Queue\SerializesModels;
/**
* Class UserAccepted
* @package App\Events
*/
class UserAccepted
{
@@ -19,6 +18,7 @@ class UserAccepted
/**
* UserAccepted constructor.
*
* @param User $user
*/
public function __construct(User $user)

View File

@@ -9,7 +9,6 @@ use Illuminate\Queue\SerializesModels;
/**
* Class UserRegistered
* @package App\Events
*/
class UserRegistered
{
@@ -19,6 +18,7 @@ class UserRegistered
/**
* UserRegistered constructor.
*
* @param User $user
*/
public function __construct(User $user)

View File

@@ -9,16 +9,17 @@ use Illuminate\Queue\SerializesModels;
/**
* Event triggered when a user's state changes
* @package App\Events
*/
class UserStateChanged
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $old_state, $user;
public $old_state;
public $user;
/**
* UserStateChanged constructor.
*
* @param User $user
* @param $old_state
*/

View File

@@ -9,15 +9,14 @@ use Illuminate\Queue\SerializesModels;
/**
* Class UserStatsChanged
* @package App\Events
*/
class UserStatsChanged
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $stat_name,
$old_value,
$user;
public $stat_name;
public $old_value;
public $user;
/*
* When a user's stats change. Stats changed match the field name:

View File

@@ -4,7 +4,6 @@ namespace App\Exceptions;
/**
* Class AircraftNotAtAirport
* @package App\Exceptions
*/
class AircraftNotAtAirport extends InternalError
{

View File

@@ -4,7 +4,6 @@ namespace App\Exceptions;
/**
* Class AircraftPermissionDenied
* @package App\Exceptions
*/
class AircraftPermissionDenied extends InternalError
{

View File

@@ -6,7 +6,6 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
/**
* Class BidExists
* @package App\Exceptions
*/
class BidExists extends HttpException
{

View File

@@ -13,7 +13,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Class Handler
* @package App\Exceptions
*/
class Handler extends ExceptionHandler
{
@@ -32,9 +31,12 @@ class Handler extends ExceptionHandler
/**
* Report or log an exception.
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
* @param \Exception $exception
* @return void
*
* @param \Exception $exception
*
* @throws Exception
*
* @return void
*/
public function report(Exception $exception)
{
@@ -43,8 +45,10 @@ class Handler extends ExceptionHandler
/**
* Create an error message
*
* @param $status_code
* @param $message
*
* @return array
*/
protected function createError($status_code, $message)
@@ -53,15 +57,16 @@ class Handler extends ExceptionHandler
'error' => [
'status' => $status_code,
'message' => $message,
]
],
];
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
*
* @return mixed
*/
public function render($request, Exception $exception)
@@ -76,7 +81,7 @@ class Handler extends ExceptionHandler
$error = $this->createError(404, $exception->getMessage());
}
# Custom exceptions should be extending HttpException
// Custom exceptions should be extending HttpException
elseif ($exception instanceof HttpException) {
$error = $this->createError(
$exception->getStatusCode(),
@@ -86,7 +91,7 @@ class Handler extends ExceptionHandler
$headers = $exception->getHeaders();
}
# Create the detailed errors from the validation errors
// Create the detailed errors from the validation errors
elseif ($exception instanceof ValidationException) {
$error_messages = [];
$errors = $exception->errors();
@@ -99,13 +104,11 @@ class Handler extends ExceptionHandler
$error['error']['errors'] = $errors;
Log::error('Validation errors', $errors);
}
else {
} else {
$error = $this->createError(400, $exception->getMessage());
}
# Only add trace if in dev
// Only add trace if in dev
if (config('app.env') === 'dev') {
$error['error']['trace'] = $exception->getTrace()[0];
}
@@ -124,8 +127,9 @@ class Handler extends ExceptionHandler
/**
* Convert an authentication exception into an unauthenticated response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Auth\AuthenticationException $exception
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Auth\AuthenticationException $exception
*
* @return \Illuminate\Http\Response
*/
protected function unauthenticated($request, AuthenticationException $exception)
@@ -140,7 +144,9 @@ class Handler extends ExceptionHandler
/**
* Render the given HttpException.
*
* @param HttpException $e
*
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
*/
protected function renderHttpException(HttpException $e)
@@ -153,7 +159,7 @@ class Handler extends ExceptionHandler
]);
if (view()->exists("errors::{$status}")) {
#if (view()->exists('layouts' . config('phpvms.skin') .'.errors.' .$status)) {
//if (view()->exists('layouts' . config('phpvms.skin') .'.errors.' .$status)) {
return response()->view("errors::{$status}", [
'exception' => $e,
'SKIN_NAME' => config('phpvms.skin'),

View File

@@ -3,14 +3,13 @@
namespace App\Exceptions;
use Illuminate\Validation\ValidationException;
use Validator;
use Log;
use Validator;
/**
* Show an internal error, bug piggyback off of the validation
* exception type - this has a place to show up in the UI as a
* flash message.
* @package App\Exceptions
*/
class InternalError extends ValidationException
{
@@ -19,6 +18,7 @@ class InternalError extends ValidationException
/**
* InternalError constructor.
*
* @param string|null $message
* @param null $field
*/

View File

@@ -6,7 +6,6 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
/**
* Class PirepCancelled
* @package App\Exceptions
*/
class PirepCancelled extends HttpException
{

View File

@@ -6,7 +6,6 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
/**
* Class SettingNotFound
* @package App\Exceptions
*/
class SettingNotFound extends HttpException
{

View File

@@ -2,10 +2,8 @@
namespace App\Exceptions;
/**
* Class UserNotAtAirport
* @package App\Exceptions
*/
class UserNotAtAirport extends InternalError
{

View File

@@ -7,7 +7,6 @@ use Illuminate\Support\Facades\Facade;
/**
* Class Utils
* @package App\Facades
*/
class Utils extends Facade
{
@@ -21,7 +20,9 @@ class Utils extends Facade
/**
* Simple check on the first character if it's an object or not
*
* @param $obj
*
* @return bool
*/
public static function isObject($obj)
@@ -40,10 +41,13 @@ class Utils extends Facade
/**
* Download a URI. If a file is given, it will save the downloaded
* content into that file
*
* @param $uri
* @param null $file
* @return string
*
* @throws \RuntimeException
*
* @return string
*/
public static function downloadUrl($uri, $file = null)
{
@@ -65,6 +69,7 @@ class Utils extends Facade
/**
* Returns a 40 character API key that a user can use
*
* @return string
*/
public static function generateApiKey()
@@ -89,13 +94,15 @@ class Utils extends Facade
/**
* Convert seconds to an array of hours, minutes, seconds
*
* @param $seconds
*
* @return array['h', 'm', 's']
*/
public static function secondsToTimeParts($seconds): array
{
$dtF = new \DateTime('@0', new \DateTimeZone('UTC'));
$dtT = new \DateTime("@$seconds", new \DateTimeZone('UTC'));
$dtF = new \DateTimeImmutable('@0', new \DateTimeZone('UTC'));
$dtT = new \DateTimeImmutable("@$seconds", new \DateTimeZone('UTC'));
$t = $dtF->diff($dtT);
@@ -109,8 +116,10 @@ class Utils extends Facade
/**
* Convert seconds to HH MM format
*
* @param $seconds
* @param bool $incl_sec
*
* @return string
*/
public static function secondsToTimeString($seconds, $incl_sec = false): string
@@ -126,6 +135,7 @@ class Utils extends Facade
/**
* @param $minutes
*
* @return float|int
*/
public static function minutesToSeconds($minutes)
@@ -135,7 +145,9 @@ class Utils extends Facade
/**
* Convert the seconds to minutes and then round it up
*
* @param $seconds
*
* @return float|int
*/
public static function secondsToMinutes($seconds)
@@ -145,7 +157,9 @@ class Utils extends Facade
/**
* Convert hours to minutes. Pretty complex
*
* @param $minutes
*
* @return float|int
*/
public static function minutesToHours($minutes)
@@ -156,6 +170,7 @@ class Utils extends Facade
/**
* @param $hours
* @param null $minutes
*
* @return float|int
*/
public static function hoursToMinutes($hours, $minutes = null)
@@ -170,8 +185,10 @@ class Utils extends Facade
/**
* Bitwise operator for setting days of week to integer field
*
* @param int $datefield initial datefield
* @param array $day_enums Array of values from config("enum.days")
*
* @return int
*/
public static function setDays(int $datefield, array $day_enums)
@@ -185,8 +202,10 @@ class Utils extends Facade
/**
* Bit check if a day exists within a integer bitfield
*
* @param int $datefield datefield from database
* @param int $day_enum Value from config("enum.days")
*
* @return bool
*/
public static function hasDay(int $datefield, int $day_enum)

View File

@@ -16,20 +16,19 @@ use App\Services\ImportService;
use Flash;
use Illuminate\Http\Request;
use Log;
use Prettus\Repository\Criteria\RequestCriteria;
use Storage;
/**
* Class AircraftController
* @package App\Http\Controllers\Admin
*/
class AircraftController extends Controller
{
private $aircraftRepo,
$importSvc;
private $aircraftRepo;
private $importSvc;
/**
* AircraftController constructor.
*
* @param AircraftRepository $aircraftRepo
* @param ImportService $importSvc
*/
@@ -43,16 +42,19 @@ class AircraftController extends Controller
/**
* Display a listing of the Aircraft.
*
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index(Request $request)
{
// If subfleet ID is passed part of the query string, then only
// show the aircraft that are in that subfleet
$w = [];
if($request->filled('subfleet')) {
if ($request->filled('subfleet')) {
$w['subfleet_id'] = $request->input('subfleet');
}
@@ -60,27 +62,30 @@ class AircraftController extends Controller
$aircraft = $aircraft->all();
return view('admin.aircraft.index', [
'aircraft' => $aircraft,
'aircraft' => $aircraft,
'subfleet_id' => $request->input('subfleet'),
]);
}
/**
* Show the form for creating a new Aircraft.
*
* @param Request $request
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function create(Request $request)
{
return view('admin.aircraft.create', [
'subfleets' => Subfleet::all()->pluck('name', 'id'),
'statuses' => AircraftStatus::select(true),
'subfleet_id' => $request->query('subfleet')
'subfleets' => Subfleet::all()->pluck('name', 'id'),
'statuses' => AircraftStatus::select(true),
'subfleet_id' => $request->query('subfleet'),
]);
}
/**
* Store a newly created Aircraft in storage.
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*/
public function store(CreateAircraftRequest $request)
@@ -94,6 +99,8 @@ class AircraftController extends Controller
/**
* Display the specified Aircraft.
*
* @param mixed $id
*/
public function show($id)
{
@@ -111,6 +118,8 @@ class AircraftController extends Controller
/**
* Show the form for editing the specified Aircraft.
*
* @param mixed $id
*/
public function edit($id)
{
@@ -130,6 +139,9 @@ class AircraftController extends Controller
/**
* Update the specified Aircraft in storage.
*
* @param mixed $id
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*/
public function update($id, UpdateAircraftRequest $request)
@@ -150,6 +162,8 @@ class AircraftController extends Controller
/**
* Remove the specified Aircraft from storage.
*
* @param mixed $id
*/
public function destroy($id)
{
@@ -168,9 +182,12 @@ class AircraftController extends Controller
/**
* Run the aircraft exporter
*
* @param Request $request
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*
* @throws \League\Csv\Exception
*
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*/
public function export(Request $request)
{
@@ -187,8 +204,10 @@ class AircraftController extends Controller
/**
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*
* @throws \Illuminate\Validation\ValidationException
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function import(Request $request)
{
@@ -215,6 +234,7 @@ class AircraftController extends Controller
/**
* @param Aircraft|null $aircraft
*
* @return mixed
*/
protected function return_expenses_view(Aircraft $aircraft)
@@ -228,10 +248,13 @@ class AircraftController extends Controller
/**
* Operations for associating ranks to the subfleet
*
* @param $id
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*
* @throws \Exception
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function expenses($id, Request $request)
{

View File

@@ -14,7 +14,6 @@ use Response;
/**
* Class AirlinesController
* @package App\Http\Controllers\Admin
*/
class AirlinesController extends Controller
{
@@ -22,14 +21,17 @@ class AirlinesController extends Controller
/**
* AirlinesController constructor.
*
* @param AirlineRepository $airlinesRepo
*/
public function __construct(AirlineRepository $airlinesRepo) {
public function __construct(AirlineRepository $airlinesRepo)
{
$this->airlineRepo = $airlinesRepo;
}
/**
* Display a listing of the Airlines.
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*/
public function index(Request $request)
@@ -54,6 +56,7 @@ class AirlinesController extends Controller
/**
* Store a newly created Airlines in storage.
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*/
public function store(CreateAirlineRequest $request)
@@ -67,7 +70,9 @@ class AirlinesController extends Controller
/**
* Display the specified Airlines.
* @param int $id
*
* @param int $id
*
* @return mixed
*/
public function show($id)
@@ -86,7 +91,9 @@ class AirlinesController extends Controller
/**
* Show the form for editing the specified Airlines.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function edit($id)
@@ -106,10 +113,13 @@ class AirlinesController extends Controller
/**
* Update the specified Airlines in storage.
* @param int $id
*
* @param int $id
* @param UpdateAirlineRequest $request
* @return Response
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return Response
*/
public function update($id, UpdateAirlineRequest $request)
{
@@ -128,7 +138,9 @@ class AirlinesController extends Controller
/**
* Remove the specified Airlines from storage.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function destroy($id)

View File

@@ -21,12 +21,11 @@ use Storage;
/**
* Class AirportController
* @package App\Http\Controllers\Admin
*/
class AirportController extends Controller
{
private $airportRepo,
$importSvc;
private $airportRepo;
private $importSvc;
/**
* @param AirportRepository $airportRepo
@@ -42,9 +41,12 @@ class AirportController extends Controller
/**
* Display a listing of the Airport.
*
* @param Request $request
* @return Response
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*
* @return Response
*/
public function index(Request $request)
{
@@ -65,6 +67,7 @@ class AirportController extends Controller
/**
* Show the form for creating a new Airport.
*
* @return Response
*/
public function create()
@@ -76,9 +79,12 @@ class AirportController extends Controller
/**
* Store a newly created Airport in storage.
*
* @param CreateAirportRequest $request
* @return Response
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return Response
*/
public function store(CreateAirportRequest $request)
{
@@ -93,7 +99,9 @@ class AirportController extends Controller
/**
* Display the specified Airport.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function show($id)
@@ -112,7 +120,9 @@ class AirportController extends Controller
/**
* Show the form for editing the specified Airport.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function edit($id)
@@ -132,10 +142,13 @@ class AirportController extends Controller
/**
* Update the specified Airport in storage.
* @param int $id
*
* @param int $id
* @param UpdateAirportRequest $request
* @return Response
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return Response
*/
public function update($id, UpdateAirportRequest $request)
{
@@ -157,7 +170,9 @@ class AirportController extends Controller
/**
* Remove the specified Airport from storage.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function destroy($id)
@@ -177,9 +192,12 @@ class AirportController extends Controller
/**
* Run the airport exporter
*
* @param Request $request
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*
* @throws \League\Csv\Exception
*
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*/
public function export(Request $request)
{
@@ -195,10 +213,11 @@ class AirportController extends Controller
}
/**
*
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*
* @throws \Illuminate\Validation\ValidationException
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function import(Request $request)
{
@@ -225,6 +244,7 @@ class AirportController extends Controller
/**
* @param Airport $airport
*
* @return mixed
*/
protected function return_expenses_view(Airport $airport)
@@ -237,10 +257,13 @@ class AirportController extends Controller
/**
* Operations for associating ranks to the subfleet
*
* @param $id
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*
* @throws \Exception
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function expenses($id, Request $request)
{
@@ -273,7 +296,9 @@ class AirportController extends Controller
/**
* Set fuel prices for this airport
*
* @param Request $request
*
* @return mixed
*/
public function fuel(Request $request)

View File

@@ -14,20 +14,20 @@ use Response;
class AwardController extends Controller
{
/** @var AwardRepository */
private $awardRepository,
$awardSvc;
/** @var AwardRepository */
private $awardRepository;
private $awardSvc;
/**
* AwardController constructor.
*
* @param AwardRepository $awardRepo
* @param AwardService $awardSvc
*/
public function __construct(
AwardRepository $awardRepo,
AwardService $awardSvc
)
{
) {
$this->awardRepository = $awardRepo;
$this->awardSvc = $awardSvc;
}
@@ -57,9 +57,12 @@ class AwardController extends Controller
/**
* Display a listing of the Fare.
*
* @param Request $request
* @return Response
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*
* @return Response
*/
public function index(Request $request)
{
@@ -73,6 +76,7 @@ class AwardController extends Controller
/**
* Show the form for creating a new Fare.
*
* @return Response
*/
public function create()
@@ -87,9 +91,12 @@ class AwardController extends Controller
/**
* Store a newly created Fare in storage.
*
* @param CreateAwardRequest $request
* @return Response
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return Response
*/
public function store(CreateAwardRequest $request)
{
@@ -102,7 +109,9 @@ class AwardController extends Controller
/**
* Display the specified Fare.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function show($id)
@@ -121,7 +130,9 @@ class AwardController extends Controller
/**
* Show the form for editing the specified award.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function edit($id)
@@ -144,10 +155,13 @@ class AwardController extends Controller
/**
* Update the specified award in storage.
* @param int $id
*
* @param int $id
* @param UpdateAwardRequest $request
* @return Response
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return Response
*/
public function update($id, UpdateAwardRequest $request)
{
@@ -167,7 +181,7 @@ class AwardController extends Controller
/**
* Remove the specified Fare from storage.
*
* @param int $id
* @param int $id
*
* @return Response
*/

View File

@@ -16,16 +16,16 @@ use vierbergenlars\SemVer\version as semver;
/**
* Class DashboardController
* @package App\Http\Controllers\Admin
*/
class DashboardController extends Controller
{
private $newsRepo,
$pirepRepo,
$userRepo;
private $newsRepo;
private $pirepRepo;
private $userRepo;
/**
* DashboardController constructor.
*
* @param NewsRepository $newsRepo
* @param PirepRepository $pirepRepo
* @param UserRepository $userRepo
@@ -44,6 +44,7 @@ class DashboardController extends Controller
* Check if a new version is available by checking the VERSION file from
* S3 and then using the semver library to do the comparison. Just show
* a session flash file on this page that'll get cleared right away
*
* @throws \RuntimeException
*/
protected function checkNewVersion()
@@ -63,6 +64,7 @@ class DashboardController extends Controller
/**
* Show the admin dashboard
*
* @throws \RuntimeException
*/
public function index(Request $request)
@@ -78,8 +80,10 @@ class DashboardController extends Controller
/**
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function news(Request $request)
{

View File

@@ -19,16 +19,16 @@ use Storage;
/**
* Class ExpenseController
* @package App\Http\Controllers\Admin
*/
class ExpenseController extends Controller
{
private $airlineRepo,
$expenseRepo,
$importSvc;
private $airlineRepo;
private $expenseRepo;
private $importSvc;
/**
* expensesController constructor.
*
* @param AirlineRepository $airlineRepo
* @param ExpenseRepository $expenseRepo
* @param ImportService $importSvc
@@ -45,19 +45,22 @@ class ExpenseController extends Controller
/**
* Display a listing of the expenses.
*
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index(Request $request)
{
$this->expenseRepo->pushCriteria(new RequestCriteria($request));
$expenses = $this->expenseRepo->findWhere([
'ref_model' => Expense::class
'ref_model' => Expense::class,
]);
return view('admin.expenses.index', [
'expenses' => $expenses
'expenses' => $expenses,
]);
}
@@ -74,9 +77,12 @@ class ExpenseController extends Controller
/**
* Store a newly created expenses in storage.
*
* @param Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function store(Request $request)
{
@@ -91,7 +97,9 @@ class ExpenseController extends Controller
/**
* Display the specified expenses.
* @param int $id
*
* @param int $id
*
* @return mixed
*/
public function show($id)
@@ -111,7 +119,9 @@ class ExpenseController extends Controller
/**
* Show the form for editing the specified expenses.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function edit($id)
@@ -133,10 +143,13 @@ class ExpenseController extends Controller
/**
* Update the specified expenses in storage.
* @param int $id
*
* @param int $id
* @param Request $request
* @return Response
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return Response
*/
public function update($id, Request $request)
{
@@ -157,7 +170,9 @@ class ExpenseController extends Controller
/**
* Remove the specified expenses from storage.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function destroy($id)
@@ -177,9 +192,12 @@ class ExpenseController extends Controller
/**
* Run the airport exporter
*
* @param Request $request
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*
* @throws \League\Csv\Exception
*
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*/
public function export(Request $request)
{
@@ -195,10 +213,11 @@ class ExpenseController extends Controller
}
/**
*
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*
* @throws \Illuminate\Validation\ValidationException
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function import(Request $request)
{

View File

@@ -18,15 +18,15 @@ use Storage;
/**
* Class FareController
* @package App\Http\Controllers\Admin
*/
class FareController extends Controller
{
private $fareRepo,
$importSvc;
private $fareRepo;
private $importSvc;
/**
* FareController constructor.
*
* @param FareRepository $fareRepo
* @param ImportService $importSvc
*/
@@ -40,9 +40,12 @@ class FareController extends Controller
/**
* Display a listing of the Fare.
*
* @param Request $request
* @return Response
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*
* @return Response
*/
public function index(Request $request)
{
@@ -65,9 +68,12 @@ class FareController extends Controller
/**
* Store a newly created Fare in storage.
*
* @param CreateFareRequest $request
* @return Response
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return Response
*/
public function store(CreateFareRequest $request)
{
@@ -80,7 +86,9 @@ class FareController extends Controller
/**
* Display the specified Fare.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function show($id)
@@ -96,7 +104,9 @@ class FareController extends Controller
/**
* Show the form for editing the specified Fare.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function edit($id)
@@ -112,10 +122,13 @@ class FareController extends Controller
/**
* Update the specified Fare in storage.
* @param int $id
*
* @param int $id
* @param UpdateFareRequest $request
* @return Response
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return Response
*/
public function update($id, UpdateFareRequest $request)
{
@@ -133,7 +146,9 @@ class FareController extends Controller
/**
* Remove the specified Fare from storage.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function destroy($id)
@@ -152,9 +167,12 @@ class FareController extends Controller
/**
* Run the aircraft exporter
*
* @param Request $request
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*
* @throws \League\Csv\Exception
*
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*/
public function export(Request $request)
{
@@ -170,10 +188,11 @@ class FareController extends Controller
}
/**
*
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*
* @throws \Illuminate\Validation\ValidationException
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function import(Request $request)
{

View File

@@ -14,7 +14,6 @@ use Validator;
/**
* Class FileController
* @package App\Http\Controllers\Admin
*/
class FileController extends Controller
{
@@ -27,9 +26,12 @@ class FileController extends Controller
/**
* Store a newly file
*
* @param Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws \Hashids\HashidsException
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function store(Request $request)
{
@@ -41,7 +43,7 @@ class FileController extends Controller
$validator = Validator::make($request->all(), [
'filename' => 'required',
'file_description' => 'nullable',
'file' => 'required|file'
'file' => 'required|file',
]);
if ($validator->fails()) {
@@ -50,7 +52,6 @@ class FileController extends Controller
Log::info('Uploading files', $attrs);
$file = $request->file('file');
$this->fileSvc->saveFile($file, 'files', [
'name' => $attrs['filename'],
@@ -65,9 +66,12 @@ class FileController extends Controller
/**
* Remove the file from storage.
*
* @param $id
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws \Exception
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function destroy($id)
{

View File

@@ -13,14 +13,13 @@ use Illuminate\Http\Request;
/**
* Class FinanceController
* @package App\Http\Controllers\Admin
*/
class FinanceController extends Controller
{
private $airlineRepo;
/**
* @param AirlineRepository $airlineRepo
* @param AirlineRepository $airlineRepo
*/
public function __construct(
AirlineRepository $airlineRepo
@@ -30,10 +29,13 @@ class FinanceController extends Controller
/**
* Display the summation tables for a given month by airline
*
* @param Request $request
* @return mixed
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*
* @return mixed
*/
public function index(Request $request)
{
@@ -48,15 +50,15 @@ class FinanceController extends Controller
$transaction_groups = [];
$airlines = $this->airlineRepo->orderBy('icao')->all();
# group by the airline
// group by the airline
foreach ($airlines as $airline) {
# Return all the transactions, grouped by the transaction group
// Return all the transactions, grouped by the transaction group
$transactions = JournalTransaction::groupBy('transaction_group', 'currency')
->selectRaw('transaction_group, currency,
SUM(credit) as sum_credits,
SUM(debit) as sum_debits')
->where([
'journal_id' => $airline->journal->id
'journal_id' => $airline->journal->id,
])
->whereBetween('created_at', $between, 'AND')
->orderBy('sum_credits', 'desc')
@@ -64,7 +66,7 @@ class FinanceController extends Controller
->orderBy('transaction_group', 'asc')
->get();
# Summate it so we can show it on the footer of the table
// Summate it so we can show it on the footer of the table
$sum_all_credits = 0;
$sum_all_debits = 0;
foreach ($transactions as $ta) {
@@ -89,6 +91,8 @@ class FinanceController extends Controller
/**
* Show a month
*
* @param mixed $id
*/
public function show($id)
{

View File

@@ -30,22 +30,22 @@ use Storage;
/**
* Class FlightController
* @package App\Http\Controllers\Admin
*/
class FlightController extends Controller
{
private $airlineRepo,
$airportRepo,
$fareRepo,
$flightRepo,
$flightFieldRepo,
$fareSvc,
$flightSvc,
$importSvc,
$subfleetRepo;
private $airlineRepo;
private $airportRepo;
private $fareRepo;
private $flightRepo;
private $flightFieldRepo;
private $fareSvc;
private $flightSvc;
private $importSvc;
private $subfleetRepo;
/**
* FlightController constructor.
*
* @param AirlineRepository $airlineRepo
* @param AirportRepository $airportRepo
* @param FareRepository $fareRepo
@@ -80,6 +80,7 @@ class FlightController extends Controller
/**
* Save any custom fields found
*
* @param Flight $flight
* @param Request $request
*/
@@ -93,8 +94,8 @@ class FlightController extends Controller
}
$custom_fields[] = [
'name' => $field->name,
'value' => $request->input($field->slug)
'name' => $field->name,
'value' => $request->input($field->slug),
];
}
@@ -104,6 +105,7 @@ class FlightController extends Controller
/**
* @param $flight
*
* @return array
*/
protected function getAvailSubfleets($flight)
@@ -123,8 +125,10 @@ class FlightController extends Controller
/**
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index(Request $request)
{
@@ -142,6 +146,7 @@ class FlightController extends Controller
/**
* Show the form for creating a new Flight.
*
* @return Response
*/
public function create()
@@ -159,8 +164,10 @@ class FlightController extends Controller
/**
* @param CreateFlightRequest $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function store(CreateFlightRequest $request)
{
@@ -190,6 +197,7 @@ class FlightController extends Controller
/**
* @param $id
*
* @return mixed
*/
public function show($id)
@@ -212,6 +220,7 @@ class FlightController extends Controller
/**
* @param $id
*
* @return mixed
*/
public function edit($id)
@@ -244,8 +253,10 @@ class FlightController extends Controller
/**
* @param $id
* @param UpdateFlightRequest $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function update($id, UpdateFlightRequest $request)
{
@@ -258,11 +269,11 @@ class FlightController extends Controller
$input = $request->all();
# apply the updates here temporarily, don't save
# the repo->update() call will actually do it
// apply the updates here temporarily, don't save
// the repo->update() call will actually do it
$flight->fill($input);
if($this->flightSvc->isFlightDuplicate($flight)) {
if ($this->flightSvc->isFlightDuplicate($flight)) {
Flash::error('Duplicate flight with same number/code/leg found, please change to proceed');
return redirect()->back()->withInput($request->all());
}
@@ -285,8 +296,10 @@ class FlightController extends Controller
/**
* @param $id
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws \Exception
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function destroy($id)
{
@@ -305,9 +318,12 @@ class FlightController extends Controller
/**
* Run the flight exporter
*
* @param Request $request
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*
* @throws \League\Csv\Exception
*
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*/
public function export(Request $request)
{
@@ -323,16 +339,17 @@ class FlightController extends Controller
}
/**
*
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*
* @throws \Illuminate\Validation\ValidationException
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function import(Request $request)
{
$logs = [
'success' => [],
'errors' => [],
'errors' => [],
];
if ($request->isMethod('post')) {
@@ -352,6 +369,7 @@ class FlightController extends Controller
/**
* @param $flight
*
* @return mixed
*/
protected function return_fields_view($flight)
@@ -366,6 +384,7 @@ class FlightController extends Controller
/**
* @param $flight_id
* @param Request $request
*
* @return mixed
*/
public function field_values($flight_id, Request $request)
@@ -388,11 +407,11 @@ class FlightController extends Controller
} elseif ($request->isMethod('put')) {
Log::info('Updating flight field, flight: '.$flight_id, $request->input());
$field = FlightFieldValue::where([
'name' => $request->input('name'),
'name' => $request->input('name'),
'flight_id' => $flight_id,
])->first();
if(!$field) {
if (!$field) {
Log::info('Field not found, creating new');
$field = new FlightFieldValue();
$field->name = $request->input('name');
@@ -401,11 +420,11 @@ class FlightController extends Controller
$field->flight_id = $flight_id;
$field->value = $request->input('value');
$field->save();
// update the field value
// update the field value
} // remove custom field from flight
elseif ($request->isMethod('delete')) {
Log::info('Deleting flight field, flight: '.$flight_id, $request->input());
if($flight_id && $request->input('field_id')) {
if ($flight_id && $request->input('field_id')) {
FlightFieldValue::destroy($request->input('field_id'));
}
}
@@ -415,6 +434,7 @@ class FlightController extends Controller
/**
* @param $flight
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
protected function return_subfleet_view($flight)
@@ -430,6 +450,7 @@ class FlightController extends Controller
/**
* @param $id
* @param Request $request
*
* @return mixed
*/
public function subfleets($id, Request $request)
@@ -444,7 +465,7 @@ class FlightController extends Controller
// add aircraft to flight
$subfleet = $this->subfleetRepo->findWithoutFail($request->subfleet_id);
if(!$subfleet) {
if (!$subfleet) {
return $this->return_subfleet_view($flight);
}
@@ -460,6 +481,8 @@ class FlightController extends Controller
/**
* Get all the fares that haven't been assigned to a given subfleet
*
* @param mixed $flight
*/
protected function getAvailFares($flight)
{
@@ -475,6 +498,7 @@ class FlightController extends Controller
/**
* @param Flight $flight
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
protected function return_fares_view(Flight $flight)
@@ -489,6 +513,7 @@ class FlightController extends Controller
/**
* @param Request $request
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function fares(Request $request)
@@ -515,7 +540,7 @@ class FlightController extends Controller
'value' => 'nullable', // regex:/([\d%]*)/
]);
/**
/*
* update specific fare data
*/
if ($request->isMethod('post')) {

View File

@@ -11,7 +11,6 @@ use Response;
/**
* Class FlightFieldController
* @package App\Http\Controllers\Admin
*/
class FlightFieldController extends Controller
{
@@ -19,6 +18,7 @@ class FlightFieldController extends Controller
/**
* FlightFieldController constructor.
*
* @param FlightFieldRepository $flightFieldRepository
*/
public function __construct(
@@ -29,9 +29,12 @@ class FlightFieldController extends Controller
/**
* Display a listing of the FlightField.
*
* @param Request $request
* @return Response
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*
* @return Response
*/
public function index(Request $request)
{
@@ -45,6 +48,7 @@ class FlightFieldController extends Controller
/**
* Show the form for creating a new FlightField.
*
* @return Response
*/
public function create()
@@ -54,9 +58,12 @@ class FlightFieldController extends Controller
/**
* Store a newly created FlightField in storage.
*
* @param Request $request
* @return Response
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return Response
*/
public function store(Request $request)
{
@@ -71,7 +78,9 @@ class FlightFieldController extends Controller
/**
* Display the specified FlightField.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function show($id)
@@ -90,7 +99,9 @@ class FlightFieldController extends Controller
/**
* Show the form for editing the specified FlightField.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function edit($id)
@@ -109,10 +120,13 @@ class FlightFieldController extends Controller
/**
* Update the specified FlightField in storage.
*
* @param $id
* @param Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function update($id, Request $request)
{
@@ -133,7 +147,9 @@ class FlightFieldController extends Controller
/**
* Remove the specified FlightField from storage.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function destroy($id)

View File

@@ -8,7 +8,6 @@ use App\Http\Requests\UpdatePirepRequest;
use App\Interfaces\Controller;
use App\Models\Enums\PirepSource;
use App\Models\Enums\PirepState;
use App\Models\Enums\PirepStatus;
use App\Models\Pirep;
use App\Models\PirepComment;
use App\Repositories\AircraftRepository;
@@ -31,23 +30,23 @@ use Response;
/**
* Class PirepController
* @package App\Http\Controllers\Admin
*/
class PirepController extends Controller
{
private $airportRepo,
$airlineRepo,
$aircraftRepo,
$fareSvc,
$journalRepo,
$pirepSvc,
$pirepRepo,
$pirepFieldRepo,
$subfleetRepo,
$userSvc;
private $airportRepo;
private $airlineRepo;
private $aircraftRepo;
private $fareSvc;
private $journalRepo;
private $pirepSvc;
private $pirepRepo;
private $pirepFieldRepo;
private $subfleetRepo;
private $userSvc;
/**
* PirepController constructor.
*
* @param AirportRepository $airportRepo
* @param AirlineRepository $airlineRepo
* @param AircraftRepository $aircraftRepo
@@ -85,7 +84,9 @@ class PirepController extends Controller
/**
* Dropdown with aircraft grouped by subfleet
*
* @param null $user
*
* @return array
*/
public function aircraftList($user = null)
@@ -112,6 +113,7 @@ class PirepController extends Controller
/**
* Save any custom fields found
*
* @param Pirep $pirep
* @param Request $request
*/
@@ -127,7 +129,7 @@ class PirepController extends Controller
$custom_fields[] = [
'name' => $field->name,
'value' => $request->input($field->slug),
'source' => PirepSource::MANUAL
'source' => PirepSource::MANUAL,
];
}
@@ -137,8 +139,10 @@ class PirepController extends Controller
/**
* Save the fares that have been specified/saved
*
* @param Pirep $pirep
* @param Request $request
*
* @throws \Exception
*/
protected function saveFares(Pirep $pirep, Request $request)
@@ -163,7 +167,9 @@ class PirepController extends Controller
/**
* Return the fares form for a given aircraft
*
* @param Request $request
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function fares(Request $request)
@@ -182,8 +188,10 @@ class PirepController extends Controller
/**
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index(Request $request)
{
@@ -194,19 +202,21 @@ class PirepController extends Controller
->whereNotInOrder('state', [
PirepState::CANCELLED,
PirepState::DRAFT,
PirepState::IN_PROGRESS
PirepState::IN_PROGRESS,
], 'created_at', 'desc')
->paginate();
return view('admin.pireps.index', [
'pireps' => $pireps
'pireps' => $pireps,
]);
}
/**
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function pending(Request $request)
{
@@ -219,12 +229,13 @@ class PirepController extends Controller
->paginate();
return view('admin.pireps.index', [
'pireps' => $pireps
'pireps' => $pireps,
]);
}
/**
* Show the form for creating a new Pirep.
*
* @return Response
*/
public function create()
@@ -238,9 +249,11 @@ class PirepController extends Controller
/**
* @param CreatePirepRequest $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
* @throws \Exception
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function store(CreatePirepRequest $request)
{
@@ -261,7 +274,9 @@ class PirepController extends Controller
/**
* Display the specified Pirep.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function show($id)
@@ -280,9 +295,12 @@ class PirepController extends Controller
/**
* Show the form for editing the specified Pirep.
* @param int $id
* @return Response
*
* @param int $id
*
* @throws \InvalidArgumentException
*
* @return Response
*/
public function edit($id)
{
@@ -296,13 +314,13 @@ class PirepController extends Controller
$pirep->hours = $time->hours;
$pirep->minutes = $time->minutes;
# set the custom fields
// set the custom fields
foreach ($pirep->fields as $field) {
$field_name = 'field_'.$field->slug;
$pirep->{$field_name} = $field->value;
}
# set the fares
// set the fares
foreach ($pirep->fares as $fare) {
$field_name = 'fare_'.$fare->fare_id;
$pirep->{$field_name} = $fare->count;
@@ -323,9 +341,11 @@ class PirepController extends Controller
/**
* @param $id
* @param UpdatePirepRequest $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
* @throws \Exception
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function update($id, UpdatePirepRequest $request)
{
@@ -341,7 +361,7 @@ class PirepController extends Controller
$attrs = $request->all();
# Fix the time
// Fix the time
$attrs['flight_time'] = Time::init(
$attrs['minutes'],
$attrs['hours'])->getMinutes();
@@ -362,7 +382,9 @@ class PirepController extends Controller
/**
* Remove the specified Pirep from storage.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function destroy($id)
@@ -382,7 +404,9 @@ class PirepController extends Controller
/**
* Change or update the PIREP status. Just return the new actionbar
*
* @param Request $request
*
* @return \Illuminate\View\View
*/
public function status(Request $request)
@@ -402,10 +426,13 @@ class PirepController extends Controller
/**
* Add a comment to the Pirep
*
* @param $id
* @param Request $request
* @return mixed
*
* @throws \Exception
*
* @return mixed
*/
public function comments($id, Request $request)
{

View File

@@ -13,7 +13,6 @@ use Response;
/**
* Class PirepFieldController
* @package App\Http\Controllers\Admin
*/
class PirepFieldController extends Controller
{
@@ -21,6 +20,7 @@ class PirepFieldController extends Controller
/**
* PirepFieldController constructor.
*
* @param PirepFieldRepository $pirepFieldRepo
*/
public function __construct(
@@ -31,9 +31,12 @@ class PirepFieldController extends Controller
/**
* Display a listing of the PirepField.
*
* @param Request $request
* @return Response
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*
* @return Response
*/
public function index(Request $request)
{
@@ -47,6 +50,7 @@ class PirepFieldController extends Controller
/**
* Show the form for creating a new PirepField.
*
* @return Response
*/
public function create()
@@ -56,9 +60,12 @@ class PirepFieldController extends Controller
/**
* Store a newly created PirepField in storage.
*
* @param CreatePirepFieldRequest $request
* @return Response
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return Response
*/
public function store(CreatePirepFieldRequest $request)
{
@@ -75,7 +82,9 @@ class PirepFieldController extends Controller
/**
* Display the specified PirepField.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function show($id)
@@ -95,7 +104,9 @@ class PirepFieldController extends Controller
/**
* Show the form for editing the specified PirepField.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function edit($id)
@@ -115,6 +126,9 @@ class PirepFieldController extends Controller
/**
* Update the specified PirepField in storage.
*
* @param mixed $id
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*/
public function update($id, UpdatePirepFieldRequest $request)
@@ -139,7 +153,9 @@ class PirepFieldController extends Controller
/**
* Remove the specified PirepField from storage.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function destroy($id)

View File

@@ -16,16 +16,16 @@ use Response;
/**
* Class RankController
* @package App\Http\Controllers\Admin
*/
class RankController extends Controller
{
private $fleetSvc,
$rankRepository,
$subfleetRepo;
private $fleetSvc;
private $rankRepository;
private $subfleetRepo;
/**
* RankController constructor.
*
* @param FleetService $fleetSvc
* @param RankRepository $rankingRepo
* @param SubfleetRepository $subfleetRepo
@@ -42,7 +42,9 @@ class RankController extends Controller
/**
* Get the available subfleets for a rank
*
* @param $rank
*
* @return array
*/
protected function getAvailSubfleets($rank)
@@ -60,9 +62,12 @@ class RankController extends Controller
/**
* Display a listing of the Ranking.
*
* @param Request $request
* @return Response
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*
* @return Response
*/
public function index(Request $request)
{
@@ -86,9 +91,12 @@ class RankController extends Controller
/**
* Store a newly created Ranking in storage.
*
* @param CreateRankRequest $request
* @return Response
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return Response
*/
public function store(CreateRankRequest $request)
{
@@ -104,7 +112,9 @@ class RankController extends Controller
/**
* Display the specified Ranking.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function show($id)
@@ -118,13 +128,15 @@ class RankController extends Controller
}
return view('admin.ranks.show', [
'rank' => $rank
'rank' => $rank,
]);
}
/**
* Show the form for editing the specified Ranking.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function edit($id)
@@ -147,10 +159,13 @@ class RankController extends Controller
/**
* Update the specified Ranking in storage.
* @param int $id
*
* @param int $id
* @param UpdateRankRequest $request
* @return Response
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return Response
*/
public function update($id, UpdateRankRequest $request)
{
@@ -172,7 +187,9 @@ class RankController extends Controller
/**
* Remove the specified Ranking from storage.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function destroy($id)
@@ -194,6 +211,7 @@ class RankController extends Controller
/**
* @param $rank
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
protected function return_subfleet_view($rank)
@@ -208,8 +226,10 @@ class RankController extends Controller
/**
* Subfleet operations on a rank
*
* @param $id
* @param Request $request
*
* @return mixed
*/
public function subfleets($id, Request $request)

View File

@@ -9,7 +9,6 @@ use Log;
/**
* Class SettingsController
* @package App\Http\Controllers\Admin
*/
class SettingsController extends Controller
{
@@ -28,7 +27,9 @@ class SettingsController extends Controller
/**
* Update the specified setting in storage.
*
* @param Request $request
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function update(Request $request)

View File

@@ -27,20 +27,20 @@ use Storage;
/**
* Class SubfleetController
* @package App\Http\Controllers\Admin
*/
class SubfleetController extends Controller
{
private $aircraftRepo,
$fareRepo,
$fareSvc,
$fleetSvc,
$importSvc,
$rankRepo,
$subfleetRepo;
private $aircraftRepo;
private $fareRepo;
private $fareSvc;
private $fleetSvc;
private $importSvc;
private $rankRepo;
private $subfleetRepo;
/**
* SubfleetController constructor.
*
* @param AircraftRepository $aircraftRepo
* @param FleetService $fleetSvc
* @param FareRepository $fareRepo
@@ -69,7 +69,9 @@ class SubfleetController extends Controller
/**
* Get the ranks that are available to the subfleet
*
* @param $subfleet
*
* @return array
*/
protected function getAvailRanks($subfleet)
@@ -86,6 +88,8 @@ class SubfleetController extends Controller
/**
* Get all the fares that haven't been assigned to a given subfleet
*
* @param mixed $subfleet
*/
protected function getAvailFares($subfleet)
{
@@ -104,9 +108,12 @@ class SubfleetController extends Controller
/**
* Display a listing of the Subfleet.
*
* @param Request $request
* @return Response
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*
* @return Response
*/
public function index(Request $request)
{
@@ -120,6 +127,7 @@ class SubfleetController extends Controller
/**
* Show the form for creating a new Subfleet.
*
* @return Response
*/
public function create()
@@ -132,9 +140,12 @@ class SubfleetController extends Controller
/**
* Store a newly created Subfleet in storage.
*
* @param CreateSubfleetRequest $request
* @return Response
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return Response
*/
public function store(CreateSubfleetRequest $request)
{
@@ -147,7 +158,9 @@ class SubfleetController extends Controller
/**
* Display the specified Subfleet.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function show($id)
@@ -168,7 +181,9 @@ class SubfleetController extends Controller
/**
* Show the form for editing the specified Subfleet.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function edit($id)
@@ -194,10 +209,13 @@ class SubfleetController extends Controller
/**
* Update the specified Subfleet in storage.
* @param int $id
*
* @param int $id
* @param UpdateSubfleetRequest $request
* @return Response
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return Response
*/
public function update($id, UpdateSubfleetRequest $request)
{
@@ -216,7 +234,9 @@ class SubfleetController extends Controller
/**
* Remove the specified Subfleet from storage.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function destroy($id)
@@ -228,8 +248,8 @@ class SubfleetController extends Controller
return redirect(route('admin.subfleets.index'));
}
# Make sure no aircraft are assigned to this subfleet
# before trying to delete it, or else things might go boom
// Make sure no aircraft are assigned to this subfleet
// before trying to delete it, or else things might go boom
$aircraft = $this->aircraftRepo->findWhere(['subfleet_id' => $id], ['id']);
if ($aircraft->count() > 0) {
Flash::error('There are aircraft still assigned to this subfleet, you can\'t delete it!')->important();
@@ -244,7 +264,9 @@ class SubfleetController extends Controller
/**
* Run the subfleet exporter
*
* @param Request $request
*
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*/
public function export(Request $request)
@@ -261,10 +283,11 @@ class SubfleetController extends Controller
}
/**
*
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*
* @throws \Illuminate\Validation\ValidationException
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function import(Request $request)
{
@@ -292,6 +315,7 @@ class SubfleetController extends Controller
/**
* @param Subfleet $subfleet
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
protected function return_ranks_view(?Subfleet $subfleet)
@@ -307,6 +331,7 @@ class SubfleetController extends Controller
/**
* @param Subfleet $subfleet
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
protected function return_fares_view(?Subfleet $subfleet)
@@ -322,8 +347,10 @@ class SubfleetController extends Controller
/**
* Operations for associating ranks to the subfleet
*
* @param $id
* @param Request $request
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function ranks($id, Request $request)
@@ -337,7 +364,7 @@ class SubfleetController extends Controller
return $this->return_ranks_view($subfleet);
}
/**
/*
* update specific rank data
*/
if ($request->isMethod('post')) {
@@ -362,6 +389,7 @@ class SubfleetController extends Controller
/**
* @param Subfleet $subfleet
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
protected function return_expenses_view(?Subfleet $subfleet)
@@ -374,10 +402,13 @@ class SubfleetController extends Controller
/**
* Operations for associating ranks to the subfleet
*
* @param $id
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*
* @throws \Exception
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function expenses($id, Request $request)
{
@@ -390,7 +421,7 @@ class SubfleetController extends Controller
return $this->return_expenses_view($subfleet);
}
/**
/*
* update specific rank data
*/
if ($request->isMethod('post')) {
@@ -413,8 +444,10 @@ class SubfleetController extends Controller
/**
* Operations on fares to the subfleet
*
* @param $id
* @param Request $request
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function fares($id, Request $request)
@@ -428,7 +461,7 @@ class SubfleetController extends Controller
return $this->return_fares_view($subfleet);
}
/**
/*
* update specific fare data
*/
if ($request->isMethod('post')) {

View File

@@ -25,18 +25,18 @@ use Response;
/**
* Class UserController
* @package App\Http\Controllers\Admin
*/
class UserController extends Controller
{
private $airlineRepo,
$airportRepo,
$pirepRepo,
$userRepo,
$userSvc;
private $airlineRepo;
private $airportRepo;
private $pirepRepo;
private $userRepo;
private $userSvc;
/**
* UserController constructor.
*
* @param AirlineRepository $airlineRepo
* @param AirportRepository $airportRepo
* @param PirepRepository $pirepRepo
@@ -59,6 +59,7 @@ class UserController extends Controller
/**
* @param Request $request
*
* @return mixed
*/
public function index(Request $request)
@@ -78,6 +79,7 @@ class UserController extends Controller
/**
* Show the form for creating a new User.
*
* @return Response
*/
public function create()
@@ -99,9 +101,12 @@ class UserController extends Controller
/**
* Store a newly created User in storage.
*
* @param CreateUserRequest $request
* @return Response
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return Response
*/
public function store(CreateUserRequest $request)
{
@@ -114,7 +119,9 @@ class UserController extends Controller
/**
* Display the specified User.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function show($id)
@@ -148,7 +155,9 @@ class UserController extends Controller
/**
* Show the form for editing the specified User.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function edit($id)
@@ -165,7 +174,7 @@ class UserController extends Controller
->whereOrder(['user_id' => $id], 'created_at', 'desc')
->paginate();
$countries = collect((new \League\ISO3166\ISO3166)->all())
$countries = collect((new \League\ISO3166\ISO3166())->all())
->mapWithKeys(function ($item, $key) {
return [strtolower($item['alpha2']) => $item['name']];
});
@@ -187,10 +196,13 @@ class UserController extends Controller
/**
* Update the specified User in storage.
*
* @param int $id
* @param UpdateUserRequest $request
* @return Response
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return Response
*/
public function update($id, UpdateUserRequest $request)
{
@@ -211,7 +223,7 @@ class UserController extends Controller
if ($request->filled('avatar_upload')) {
/**
* @var $file \Illuminate\Http\UploadedFile
* @var $file \Illuminate\Http\UploadedFile
*/
$file = $request->file('avatar_upload');
$file_path = $file->storeAs(
@@ -223,7 +235,6 @@ class UserController extends Controller
$user->avatar = $file_path;
}
$original_user_state = $user->state;
$user = $this->userRepo->update($req_data, $id);
@@ -232,7 +243,7 @@ class UserController extends Controller
$this->userSvc->changeUserState($user, $original_user_state);
}
# Delete all of the roles and then re-attach the valid ones
// Delete all of the roles and then re-attach the valid ones
DB::table('role_user')->where('user_id', $id)->delete();
foreach ($request->input('roles') as $key => $value) {
$user->attachRole($value);
@@ -245,7 +256,9 @@ class UserController extends Controller
/**
* Remove the specified User from storage.
* @param int $id
*
* @param int $id
*
* @return Response
*/
public function destroy($id)
@@ -267,8 +280,10 @@ class UserController extends Controller
/**
* Regenerate the user's API key
*
* @param $id
* @param Request $request
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function regen_apikey($id, Request $request)

View File

@@ -23,17 +23,17 @@ use Log;
/**
* Class AcarsController
* @package App\Http\Controllers\Api
*/
class AcarsController extends Controller
{
private $acarsRepo,
$geoSvc,
$pirepRepo,
$pirepSvc;
private $acarsRepo;
private $geoSvc;
private $pirepRepo;
private $pirepSvc;
/**
* AcarsController constructor.
*
* @param AcarsRepository $acarsRepo
* @param GeoService $geoSvc
* @param PirepRepository $pirepRepo
@@ -53,7 +53,9 @@ class AcarsController extends Controller
/**
* Check if a PIREP is cancelled
*
* @param $pirep
*
* @throws \App\Exceptions\PirepCancelled
*/
protected function checkCancelled(Pirep $pirep)
@@ -65,7 +67,9 @@ class AcarsController extends Controller
/**
* Return all of the flights (as points) in GeoJSON format
*
* @param Request $request
*
* @return mixed
*/
public function index(Request $request)
@@ -74,14 +78,16 @@ class AcarsController extends Controller
$positions = $this->geoSvc->getFeatureForLiveFlights($pireps);
return response(json_encode($positions), 200, [
'Content-type' => 'application/json'
'Content-type' => 'application/json',
]);
}
/**
* Return the GeoJSON for the ACARS line
*
* @param $pirep_id
* @param Request $request
*
* @return \Illuminate\Contracts\Routing\ResponseFactory
*/
public function acars_geojson($pirep_id, Request $request)
@@ -96,8 +102,10 @@ class AcarsController extends Controller
/**
* Return the routes for the ACARS line
*
* @param $id
* @param Request $request
*
* @return AcarsRouteResource
*/
public function acars_get($id, Request $request)
@@ -106,21 +114,24 @@ class AcarsController extends Controller
return new AcarsRouteResource(Acars::where([
'pirep_id' => $id,
'type' => AcarsType::FLIGHT_PATH
'type' => AcarsType::FLIGHT_PATH,
])->orderBy('sim_time', 'asc')->get());
}
/**
* Post ACARS updates for a PIREP
*
* @param $id
* @param PositionRequest $request
* @return \Illuminate\Http\JsonResponse
*
* @throws \App\Exceptions\PirepCancelled
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
*
* @return \Illuminate\Http\JsonResponse
*/
public function acars_store($id, PositionRequest $request)
{
# Check if the status is cancelled...
// Check if the status is cancelled...
$pirep = Pirep::find($id);
$this->checkCancelled($pirep);
@@ -146,10 +157,10 @@ class AcarsController extends Controller
$update = Acars::create($position);
$update->save();
++$count;
$count++;
}
# Change the PIREP status if it's as SCHEDULED before
// Change the PIREP status if it's as SCHEDULED before
if ($pirep->status === PirepStatus::INITIATED) {
$pirep->status = PirepStatus::AIRBORNE;
}
@@ -162,15 +173,18 @@ class AcarsController extends Controller
/**
* Post ACARS LOG update for a PIREP. These updates won't show up on the map
* But rather in a log file.
*
* @param $id
* @param LogRequest $request
* @return \Illuminate\Http\JsonResponse
*
* @throws \App\Exceptions\PirepCancelled
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
*
* @return \Illuminate\Http\JsonResponse
*/
public function acars_logs($id, LogRequest $request)
{
# Check if the status is cancelled...
// Check if the status is cancelled...
$pirep = Pirep::find($id);
$this->checkCancelled($pirep);
@@ -192,7 +206,7 @@ class AcarsController extends Controller
$acars = Acars::create($log);
$acars->save();
++$count;
$count++;
}
return $this->message($count.' logs added', $count);
@@ -201,15 +215,18 @@ class AcarsController extends Controller
/**
* Post ACARS LOG update for a PIREP. These updates won't show up on the map
* But rather in a log file.
*
* @param $id
* @param EventRequest $request
* @return \Illuminate\Http\JsonResponse
*
* @throws \App\Exceptions\PirepCancelled
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
*
* @return \Illuminate\Http\JsonResponse
*/
public function acars_events($id, EventRequest $request)
{
# Check if the status is cancelled...
// Check if the status is cancelled...
$pirep = Pirep::find($id);
$this->checkCancelled($pirep);
@@ -232,7 +249,7 @@ class AcarsController extends Controller
$acars = Acars::create($log);
$acars->save();
++$count;
$count++;
}
return $this->message($count.' logs added', $count);

View File

@@ -9,7 +9,6 @@ use Illuminate\Http\Request;
/**
* Class AirlineController
* @package App\Http\Controllers\Api
*/
class AirlineController extends Controller
{
@@ -17,6 +16,7 @@ class AirlineController extends Controller
/**
* AirlineController constructor.
*
* @param AirlineRepository $airlineRepo
*/
public function __construct(
@@ -27,12 +27,14 @@ class AirlineController extends Controller
/**
* Return all the airlines, paginated
*
* @param Request $request
*
* @return mixed
*/
public function index(Request $request)
{
#$this->airlineRepo->pushCriteria(new RequestCriteria($request));
//$this->airlineRepo->pushCriteria(new RequestCriteria($request));
$airports = $this->airlineRepo
->whereOrder(['active' => true], 'name', 'asc')
->paginate();
@@ -42,7 +44,9 @@ class AirlineController extends Controller
/**
* Do a lookup, via vaCentral, for the airport information
*
* @param $id
*
* @return AirlineResource
*/
public function get($id)

View File

@@ -12,7 +12,6 @@ use VaCentral\Airport as AirportLookup;
/**
* Class AirportController
* @package App\Http\Controllers\Api
*/
class AirportController extends Controller
{
@@ -20,6 +19,7 @@ class AirportController extends Controller
/**
* AirportController constructor.
*
* @param AirportRepository $airportRepo
*/
public function __construct(
@@ -30,7 +30,9 @@ class AirportController extends Controller
/**
* Return all the airports, paginated
*
* @param Request $request
*
* @return mixed
*/
public function index(Request $request)
@@ -65,7 +67,9 @@ class AirportController extends Controller
/**
* Do a lookup, via vaCentral, for the airport information
*
* @param $id
*
* @return AirportResource
*/
public function get($id)
@@ -77,7 +81,9 @@ class AirportController extends Controller
/**
* Do a lookup, via vaCentral, for the airport information
*
* @param $id
*
* @return AirportResource
*/
public function lookup($id)

View File

@@ -11,15 +11,15 @@ use Illuminate\Http\Request;
/**
* Class FleetController
* @package App\Http\Controllers\Api
*/
class FleetController extends Controller
{
private $aircraftRepo,
$subfleetRepo;
private $aircraftRepo;
private $subfleetRepo;
/**
* FleetController constructor.
*
* @param AircraftRepository $aircraftRepo
* @param SubfleetRepository $subfleetRepo
*/
@@ -47,8 +47,10 @@ class FleetController extends Controller
/**
* Get a specific aircraft. Query string required to specify the tail
* /api/aircraft/XYZ?type=registration
*
* @param $id
* @param Request $request
*
* @return AircraftResource
*/
public function get_aircraft($id, Request $request)

View File

@@ -15,15 +15,15 @@ use Prettus\Repository\Exceptions\RepositoryException;
/**
* Class FlightController
* @package App\Http\Controllers\Api
*/
class FlightController extends Controller
{
private $flightRepo,
$flightSvc;
private $flightRepo;
private $flightSvc;
/**
* FlightController constructor.
*
* @param FlightRepository $flightRepo
* @param FlightService $flightSvc
*/
@@ -37,7 +37,9 @@ class FlightController extends Controller
/**
* Return all the flights, paginated
*
* @param Request $request
*
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
*/
public function index(Request $request)
@@ -49,7 +51,7 @@ class FlightController extends Controller
'visible' => true,
];
if(setting('pilots.restrict_to_company')) {
if (setting('pilots.restrict_to_company')) {
$where['airline_id'] = Auth::user()->airline_id;
}
if (setting('pilots.only_flights_from_current', false)) {
@@ -69,6 +71,7 @@ class FlightController extends Controller
/**
* @param $id
*
* @return FlightResource
*/
public function get($id)
@@ -81,6 +84,7 @@ class FlightController extends Controller
/**
* @param Request $request
*
* @return mixed
*/
public function search(Request $request)
@@ -93,7 +97,7 @@ class FlightController extends Controller
'visible' => true,
];
if(setting('pilots.restrict_to_company')) {
if (setting('pilots.restrict_to_company')) {
$where['airline_id'] = Auth::user()->airline_id;
}
if (setting('pilots.only_flights_from_current')) {
@@ -117,8 +121,10 @@ class FlightController extends Controller
/**
* Get a flight's route
*
* @param $id
* @param Request $request
*
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
*/
public function route($id, Request $request)

View File

@@ -7,24 +7,25 @@ use App\Interfaces\Controller;
use App\Repositories\NewsRepository;
use Illuminate\Http\Request;
/**
* @package App\Http\Controllers\Api
*/
class NewsController extends Controller
{
private $newsRepo;
/**
* AirlineController constructor.
*
* @param NewsRepository $newsRepo
*/
public function __construct(NewsRepository $newsRepo) {
public function __construct(NewsRepository $newsRepo)
{
$this->newsRepo = $newsRepo;
}
/**
* Return all the airlines, paginated
*
* @param Request $request
*
* @return mixed
*/
public function index(Request $request)

View File

@@ -40,20 +40,20 @@ use Log;
/**
* Class PirepController
* @package App\Http\Controllers\Api
*/
class PirepController extends Controller
{
private $acarsRepo,
$fareSvc,
$financeSvc,
$journalRepo,
$pirepRepo,
$pirepSvc,
$userSvc;
private $acarsRepo;
private $fareSvc;
private $financeSvc;
private $journalRepo;
private $pirepRepo;
private $pirepSvc;
private $userSvc;
/**
* PirepController constructor.
*
* @param AcarsRepository $acarsRepo
* @param FareService $fareSvc
* @param PirepFinanceService $financeSvc
@@ -82,7 +82,9 @@ class PirepController extends Controller
/**
* Parse any PIREP added in
*
* @param Request $request
*
* @return array|null|string
*/
protected function parsePirep(Request $request)
@@ -98,7 +100,9 @@ class PirepController extends Controller
/**
* Check if a PIREP is cancelled
*
* @param $pirep
*
* @throws \App\Exceptions\PirepCancelled
*/
protected function checkCancelled(Pirep $pirep)
@@ -132,8 +136,10 @@ class PirepController extends Controller
/**
* Save the fares
*
* @param $pirep
* @param Request $request
*
* @throws \Exception
*/
protected function updateFares($pirep, Request $request)
@@ -155,14 +161,15 @@ class PirepController extends Controller
/**
* Get all the active PIREPs
*
* @return mixed
*/
public function index()
{
$active = [];
$pireps = $this->acarsRepo->getPositions();
foreach($pireps as $pirep) {
if(!$pirep->position) {
foreach ($pireps as $pirep) {
if (!$pirep->position) {
continue;
}
@@ -174,6 +181,7 @@ class PirepController extends Controller
/**
* @param $pirep_id
*
* @return PirepResource
*/
public function get($pirep_id)
@@ -187,12 +195,14 @@ class PirepController extends Controller
* status, and whatever other statuses may be defined
*
* @param PrefileRequest $request
* @return PirepResource
*
* @throws \App\Exceptions\AircraftNotAtAirport
* @throws \App\Exceptions\UserNotAtAirport
* @throws \App\Exceptions\PirepCancelled
* @throws \App\Exceptions\AircraftPermissionDenied
* @throws \Exception
*
* @return PirepResource
*/
public function prefile(PrefileRequest $request)
{
@@ -211,28 +221,25 @@ class PirepController extends Controller
$pirep = new Pirep($attrs);
# See if this user is at the current airport
// See if this user is at the current airport
if (setting('pilots.only_flights_from_current')
&& $user->curr_airport_id !== $pirep->dpt_airport_id)
{
&& $user->curr_airport_id !== $pirep->dpt_airport_id) {
throw new UserNotAtAirport();
}
# See if this user is allowed to fly this aircraft
// See if this user is allowed to fly this aircraft
if (setting('pireps.restrict_aircraft_to_rank', false)
&& !$this->userSvc->aircraftAllowed($user, $pirep->aircraft_id))
{
&& !$this->userSvc->aircraftAllowed($user, $pirep->aircraft_id)) {
throw new AircraftPermissionDenied();
}
# See if this aircraft is at the departure airport
// See if this aircraft is at the departure airport
if (setting('pireps.only_aircraft_at_dpt_airport')
&& $pirep->aircraft_id !== $pirep->dpt_airport_id)
{
&& $pirep->aircraft_id !== $pirep->dpt_airport_id) {
throw new AircraftNotAtAirport();
}
# Find if there's a duplicate, if so, let's work on that
// Find if there's a duplicate, if so, let's work on that
$dupe_pirep = $this->pirepSvc->findDuplicate($pirep);
if ($dupe_pirep !== false) {
$pirep = $dupe_pirep;
@@ -240,7 +247,7 @@ class PirepController extends Controller
}
// Default to a scheduled passenger flight
if(!array_key_exists('flight_type', $attrs)) {
if (!array_key_exists('flight_type', $attrs)) {
$attrs['flight_type'] = 'J';
}
@@ -262,11 +269,13 @@ class PirepController extends Controller
*
* @param $pirep_id
* @param UpdateRequest $request
* @return PirepResource
*
* @throws \App\Exceptions\PirepCancelled
* @throws \App\Exceptions\AircraftPermissionDenied
* @throws \Prettus\Validator\Exceptions\ValidatorException
* @throws \Exception
*
* @return PirepResource
*/
public function update($pirep_id, UpdateRequest $request)
{
@@ -280,7 +289,7 @@ class PirepController extends Controller
$attrs = $this->parsePirep($request);
$attrs['user_id'] = Auth::id();
# If aircraft is being changed, see if this user is allowed to fly this aircraft
// If aircraft is being changed, see if this user is allowed to fly this aircraft
if (array_key_exists('aircraft_id', $attrs)
&& setting('pireps.restrict_aircraft_to_rank', false)
) {
@@ -299,13 +308,16 @@ class PirepController extends Controller
/**
* File the PIREP
*
* @param $pirep_id
* @param FileRequest $request
* @return PirepResource
*
* @throws \App\Exceptions\PirepCancelled
* @throws \App\Exceptions\AircraftPermissionDenied
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
* @throws \Exception
*
* @return PirepResource
*/
public function file($pirep_id, FileRequest $request)
{
@@ -313,13 +325,13 @@ class PirepController extends Controller
$user = Auth::user();
# Check if the status is cancelled...
// Check if the status is cancelled...
$pirep = Pirep::find($pirep_id);
$this->checkCancelled($pirep);
$attrs = $this->parsePirep($request);
# If aircraft is being changed, see if this user is allowed to fly this aircraft
// If aircraft is being changed, see if this user is allowed to fly this aircraft
if (array_key_exists('aircraft_id', $attrs)
&& setting('pireps.restrict_aircraft_to_rank', false)
) {
@@ -343,9 +355,9 @@ class PirepController extends Controller
Log::error($e);
}
# See if there there is any route data posted
# If there isn't, then just write the route data from the
# route that's been posted from the PIREP
// See if there there is any route data posted
// If there isn't, then just write the route data from the
// route that's been posted from the PIREP
$w = ['pirep_id' => $pirep->id, 'type' => AcarsType::ROUTE];
$count = Acars::where($w)->count(['id']);
if ($count === 0) {
@@ -357,10 +369,13 @@ class PirepController extends Controller
/**
* Cancel the PIREP
*
* @param $pirep_id
* @param Request $request
* @return PirepResource
*
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return PirepResource
*/
public function cancel($pirep_id, Request $request)
{
@@ -376,7 +391,9 @@ class PirepController extends Controller
/**
* Add a new comment
* @param $id
*
* @param $id
*
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
*/
public function comments_get($id)
@@ -387,10 +404,13 @@ class PirepController extends Controller
/**
* Add a new comment
*
* @param $id
* @param CommentRequest $request
* @return PirepCommentResource
*
* @throws \App\Exceptions\PirepCancelled
*
* @return PirepCommentResource
*/
public function comments_post($id, CommentRequest $request)
{
@@ -399,7 +419,7 @@ class PirepController extends Controller
Log::debug('Posting comment, PIREP: '.$id, $request->post());
# Add it
// Add it
$comment = new PirepComment($request->post());
$comment->pirep_id = $id;
$comment->user_id = Auth::id();
@@ -410,7 +430,9 @@ class PirepController extends Controller
/**
* Get all of the fields for a PIREP
*
* @param $pirep_id
*
* @return PirepFieldCollection
*/
public function fields_get($pirep_id)
@@ -421,8 +443,10 @@ class PirepController extends Controller
/**
* Set any fields for a PIREP
*
* @param string $pirep_id
* @param FieldsRequest $request
*
* @return PirepFieldCollection
*/
public function fields_post($pirep_id, FieldsRequest $request)
@@ -436,10 +460,12 @@ class PirepController extends Controller
}
/**
* @param $id
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
* @param $id
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
*/
public function finances_get($id)
{
@@ -451,11 +477,13 @@ class PirepController extends Controller
/**
* @param $id
* @param Request $request
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
* @throws \Exception
* @throws \Prettus\Validator\Exceptions\ValidatorException
*
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
*/
public function finances_recalculate($id, Request $request)
{
@@ -471,6 +499,7 @@ class PirepController extends Controller
/**
* @param $id
* @param Request $request
*
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
*/
public function route_get($id, Request $request)
@@ -478,22 +507,25 @@ class PirepController extends Controller
$pirep = Pirep::find($id);
return AcarsRouteResource::collection(Acars::where([
'pirep_id' => $id,
'type' => AcarsType::ROUTE
'type' => AcarsType::ROUTE,
])->orderBy('order', 'asc')->get());
}
/**
* Post the ROUTE for a PIREP, can be done from the ACARS log
*
* @param $id
* @param RouteRequest $request
* @return \Illuminate\Http\JsonResponse
*
* @throws \App\Exceptions\PirepCancelled
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
* @throws \Exception
*
* @return \Illuminate\Http\JsonResponse
*/
public function route_post($id, RouteRequest $request)
{
# Check if the status is cancelled...
// Check if the status is cancelled...
$pirep = Pirep::find($id);
$this->checkCancelled($pirep);
@@ -502,7 +534,7 @@ class PirepController extends Controller
// Delete the route before posting a new one
Acars::where([
'pirep_id' => $id,
'type' => AcarsType::ROUTE
'type' => AcarsType::ROUTE,
])->delete();
$count = 0;
@@ -518,7 +550,7 @@ class PirepController extends Controller
$acars = Acars::create($position);
$acars->save();
++$count;
$count++;
}
return $this->message($count.' points added', $count);
@@ -527,8 +559,10 @@ class PirepController extends Controller
/**
* @param $id
* @param Request $request
* @return \Illuminate\Http\JsonResponse
*
* @throws \Exception
*
* @return \Illuminate\Http\JsonResponse
*/
public function route_delete($id, Request $request)
{
@@ -536,7 +570,7 @@ class PirepController extends Controller
Acars::where([
'pirep_id' => $id,
'type' => AcarsType::ROUTE
'type' => AcarsType::ROUTE,
])->delete();
return $this->message('Route deleted');

View File

@@ -9,7 +9,6 @@ use Illuminate\Http\Request;
/**
* Class SettingsController
* @package App\Http\Controllers\Api
*/
class SettingsController extends Controller
{
@@ -17,6 +16,7 @@ class SettingsController extends Controller
/**
* SettingsController constructor.
*
* @param SettingRepository $settingRepo
*/
public function __construct(
@@ -27,7 +27,9 @@ class SettingsController extends Controller
/**
* Return all the airlines, paginated
*
* @param Request $request
*
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
*/
public function index(Request $request)

View File

@@ -7,7 +7,6 @@ use PragmaRX\Version\Package\Facade as Version;
/**
* Class StatusController
* @package App\Http\Controllers\Api
*/
class StatusController extends Controller
{

View File

@@ -2,7 +2,6 @@
namespace App\Http\Controllers\Api;
use App\Exceptions\BidExists;
use App\Http\Resources\Bid as BidResource;
use App\Http\Resources\Pirep as PirepResource;
use App\Http\Resources\Subfleet as SubfleetResource;
@@ -24,19 +23,19 @@ use Prettus\Repository\Exceptions\RepositoryException;
/**
* Class UserController
* @package App\Http\Controllers\Api
*/
class UserController extends Controller
{
private $flightRepo,
$flightSvc,
$pirepRepo,
$subfleetRepo,
$userRepo,
$userSvc;
private $flightRepo;
private $flightSvc;
private $pirepRepo;
private $subfleetRepo;
private $userRepo;
private $userSvc;
/**
* UserController constructor.
*
* @param FlightRepository $flightRepo
* @param FlightService $flightSvc
* @param PirepRepository $pirepRepo
@@ -62,6 +61,7 @@ class UserController extends Controller
/**
* @param Request $request
*
* @return int|mixed
*/
protected function getUserId(Request $request)
@@ -75,7 +75,9 @@ class UserController extends Controller
/**
* Return the profile for the currently auth'd user
*
* @param Request $request
*
* @return UserResource
*/
public function index(Request $request)
@@ -85,7 +87,9 @@ class UserController extends Controller
/**
* Get the profile for the passed-in user
*
* @param $id
*
* @return UserResource
*/
public function get($id)
@@ -95,16 +99,19 @@ class UserController extends Controller
/**
* Return all of the bids for the passed-in user
*
* @param Request $request
* @return mixed
*
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
* @throws \App\Exceptions\BidExists
*
* @return mixed
*/
public function bids(Request $request)
{
$user = $this->userRepo->find($this->getUserId($request));
# Add a bid
// Add a bid
if ($request->isMethod('PUT') || $request->isMethod('POST')) {
$flight_id = $request->input('flight_id');
$flight = $this->flightRepo->find($flight_id);
@@ -125,7 +132,7 @@ class UserController extends Controller
$this->flightSvc->removeBid($flight, $user);
}
# Return the flights they currently have bids on
// Return the flights they currently have bids on
$bids = Bid::where(['user_id' => $user->id])->get();
return BidResource::collection($bids);
@@ -133,7 +140,9 @@ class UserController extends Controller
/**
* Return the fleet that this user is allowed to
*
* @param Request $request
*
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
*/
public function fleet(Request $request)
@@ -146,8 +155,10 @@ class UserController extends Controller
/**
* @param Request $request
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
*
* @throws RepositoryException
*
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
*/
public function pireps(Request $request)
{

View File

@@ -7,7 +7,6 @@ use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
/**
* Class ForgotPasswordController
* @package App\Http\Controllers\Auth
*/
class ForgotPasswordController extends Controller
{

View File

@@ -11,7 +11,6 @@ use Illuminate\Support\Facades\Log;
/**
* Class LoginController
* @package App\Http\Controllers\Auth
*/
class LoginController extends Controller
{
@@ -38,6 +37,7 @@ class LoginController extends Controller
/**
* @param Request $request
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
*/
protected function sendLoginResponse(Request $request)

View File

@@ -19,7 +19,6 @@ use Validator;
/**
* Class RegisterController
* @package App\Http\Controllers\Auth
*/
class RegisterController extends Controller
{
@@ -27,16 +26,18 @@ class RegisterController extends Controller
/**
* Where to redirect users after login / registration.
*
* @var string
*/
protected $redirectTo = '/';
private $airlineRepo,
$airportRepo,
$userService;
private $airlineRepo;
private $airportRepo;
private $userService;
/**
* RegisterController constructor.
*
* @param AirlineRepository $airlineRepo
* @param AirportRepository $airportRepo
* @param UserService $userService
@@ -72,7 +73,9 @@ class RegisterController extends Controller
/**
* Get a validator for an incoming registration request.
* @param array $data
*
* @param array $data
*
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
@@ -94,10 +97,13 @@ class RegisterController extends Controller
/**
* Get a validator for an incoming registration request.
* @param array $data
* @return User
*
* @param array $data
*
* @throws \RuntimeException
* @throws \Exception
*
* @return User
*/
protected function create(array $data)
{
@@ -119,9 +125,12 @@ class RegisterController extends Controller
/**
* Handle a registration request for the application.
*
* @param Request $request
* @return mixed
*
* @throws \Exception
*
* @return mixed
*/
public function register(Request $request)
{

Some files were not shown because too many files have changed in this diff Show More