Apply fixes from StyleCI

This commit is contained in:
Nabeel Shahzad 2018-08-26 16:40:04 +00:00 committed by StyleCI Bot
parent 20f46adbc4
commit 9596d88b48
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 * 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 * has 100 flights. All award classes need to extend the AwardInterface
* @package App\Awards
*/ */
class PilotFlightAwards extends Award class PilotFlightAwards extends Award
{ {
/** /**
* Set the name of this award class to make it easier to see when * Set the name of this award class to make it easier to see when
* assigning to a specific award * assigning to a specific award
*
* @var string * @var string
*/ */
public $name = 'Pilot Flights'; public $name = 'Pilot Flights';
@ -22,6 +22,7 @@ class PilotFlightAwards extends Award
* The description to show under the parameters field, so the admin knows * The description to show under the parameters field, so the admin knows
* what the parameter actually controls. You can leave this blank if there * what the parameter actually controls. You can leave this blank if there
* isn't a parameter. * isn't a parameter.
*
* @var string * @var string
*/ */
public $param_description = 'The number of flights at which to give this award'; 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 * 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 * is a parameter or not. You can call it whatever you want, since that would make
* sense with the $param_description. * sense with the $param_description.
*
* @param int|null $number_of_flights The parameters passed in from the UI * @param int|null $number_of_flights The parameters passed in from the UI
*
* @return bool * @return bool
*/ */
public function check($number_of_flights = null): bool public function check($number_of_flights = null): bool

View File

@ -7,30 +7,22 @@ use Illuminate\Contracts\Foundation\Application;
/** /**
* Class LoadConfiguration * 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 class LoadConfiguration extends \Illuminate\Foundation\Bootstrap\LoadConfiguration
{ {
/** /**
* Load the configuration items from all of the files. * Load the configuration items from all of the files.
* *
* @param \Illuminate\Contracts\Foundation\Application $app * @param \Illuminate\Contracts\Foundation\Application $app
* @param \Illuminate\Contracts\Config\Repository $repository * @param \Illuminate\Contracts\Config\Repository $repository
*
* @throws \Exception * @throws \Exception
*/ */
protected function loadConfigurationFiles(Application $app, RepositoryContract $repository) protected function loadConfigurationFiles(Application $app, RepositoryContract $repository)
{ {
parent::loadConfigurationFiles($app, $repository); parent::loadConfigurationFiles($app, $repository);
/** /*
* Read in the base config, only if it exists * Read in the base config, only if it exists
*/ */
if (file_exists($app->basePath().'/config.php')) { if (file_exists($app->basePath().'/config.php')) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,7 +11,6 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
/** /**
* Class Kernel * Class Kernel
* @package App\Console
*/ */
class Kernel extends ConsoleKernel class Kernel extends ConsoleKernel
{ {
@ -27,7 +26,9 @@ class Kernel extends ConsoleKernel
/** /**
* Define the application's command schedule. * Define the application's command schedule.
* @param \Illuminate\Console\Scheduling\Schedule $schedule *
* @param \Illuminate\Console\Scheduling\Schedule $schedule
*
* @return void * @return void
*/ */
protected function schedule(Schedule $schedule): void protected function schedule(Schedule $schedule): void
@ -40,6 +41,7 @@ class Kernel extends ConsoleKernel
/** /**
* Register the Closure based commands for the application. * Register the Closure based commands for the application.
*
* @return void * @return void
*/ */
protected function commands(): 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 * Just a simple custom logger that dumps to the console
* @package App\Console
*/ */
class Logger class Logger
{ {
public function __invoke(array $config) public function __invoke(array $config)
{ {
$logger = new \Monolog\Logger('console'); $logger = new \Monolog\Logger('console');
try { try {
$logger->pushHandler(new StreamHandler('php://stdout')); $logger->pushHandler(new StreamHandler('php://stdout'));
} catch (\Exception $e) { } catch (\Exception $e) {

View File

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

View File

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

View File

@ -9,7 +9,6 @@ use App\Services\Finance\RecurringFinanceService;
/** /**
* Go through and apply any finances that are daily * Go through and apply any finances that are daily
* @package App\Listeners\Cron\Nightly
*/ */
class ApplyExpenses extends Listener class ApplyExpenses extends Listener
{ {
@ -17,6 +16,7 @@ class ApplyExpenses extends Listener
/** /**
* ApplyExpenses constructor. * ApplyExpenses constructor.
*
* @param RecurringFinanceService $financeSvc * @param RecurringFinanceService $financeSvc
*/ */
public function __construct(RecurringFinanceService $financeSvc) public function __construct(RecurringFinanceService $financeSvc)
@ -26,7 +26,9 @@ class ApplyExpenses extends Listener
/** /**
* Apply all of the expenses for a month * Apply all of the expenses for a month
*
* @param CronMonthly $event * @param CronMonthly $event
*
* @throws \UnexpectedValueException * @throws \UnexpectedValueException
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @throws \Prettus\Validator\Exceptions\ValidatorException * @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 * Go through and apply any finances that are daily
* @package App\Listeners\Cron\Nightly
*/ */
class ApplyExpenses extends Listener class ApplyExpenses extends Listener
{ {
@ -17,6 +16,7 @@ class ApplyExpenses extends Listener
/** /**
* ApplyExpenses constructor. * ApplyExpenses constructor.
*
* @param RecurringFinanceService $financeSvc * @param RecurringFinanceService $financeSvc
*/ */
public function __construct(RecurringFinanceService $financeSvc) public function __construct(RecurringFinanceService $financeSvc)
@ -26,7 +26,9 @@ class ApplyExpenses extends Listener
/** /**
* Apply all of the expenses for a day * Apply all of the expenses for a day
*
* @param CronNightly $event * @param CronNightly $event
*
* @throws \UnexpectedValueException * @throws \UnexpectedValueException
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @throws \Prettus\Validator\Exceptions\ValidatorException * @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 * Determine if any pilots should be set to ON LEAVE status
* @package App\Listeners\Cron\Nightly
*/ */
class PilotLeave extends Listener class PilotLeave extends Listener
{ {
@ -27,13 +26,15 @@ class PilotLeave extends Listener
/** /**
* Set any users to being on leave after X days * Set any users to being on leave after X days
*
* @param CronNightly $event * @param CronNightly $event
*
* @throws \UnexpectedValueException * @throws \UnexpectedValueException
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public function handle(CronNightly $event): void public function handle(CronNightly $event): void
{ {
if(setting('pilots.auto_leave_days') === 0) { if (setting('pilots.auto_leave_days') === 0) {
return; return;
} }
@ -41,7 +42,7 @@ class PilotLeave extends Listener
$users = User::where('status', UserState::ACTIVE) $users = User::where('status', UserState::ACTIVE)
->whereDate('updated_at', '<', $date); ->whereDate('updated_at', '<', $date);
foreach($users as $user) { foreach ($users as $user) {
Log::info('Setting user '.$user->ident.' to ON LEAVE status'); Log::info('Setting user '.$user->ident.' to ON LEAVE status');
$this->userSvc->setStatusOnLeave($user); $this->userSvc->setStatusOnLeave($user);
} }

View File

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

View File

@ -5,19 +5,17 @@ namespace App\Cron\Nightly;
use App\Events\CronNightly; use App\Events\CronNightly;
use App\Interfaces\Listener; use App\Interfaces\Listener;
use App\Models\Enums\UserState; use App\Models\Enums\UserState;
use App\Models\Journal;
use App\Repositories\UserRepository; use App\Repositories\UserRepository;
use App\Services\UserService; use App\Services\UserService;
use Log; use Log;
/** /**
* This recalculates the balances on all of the journals * This recalculates the balances on all of the journals
* @package App\Listeners\Cron
*/ */
class RecalculateStats extends Listener class RecalculateStats extends Listener
{ {
private $userRepo, private $userRepo;
$userSvc; private $userSvc;
public function __construct(UserRepository $userRepo, UserService $userService) public function __construct(UserRepository $userRepo, UserService $userService)
{ {
@ -27,7 +25,9 @@ class RecalculateStats extends Listener
/** /**
* Recalculate the stats for active users * Recalculate the stats for active users
*
* @param CronNightly $event * @param CronNightly $event
*
* @throws \UnexpectedValueException * @throws \UnexpectedValueException
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
@ -36,7 +36,7 @@ class RecalculateStats extends Listener
Log::info('Recalculating balances'); Log::info('Recalculating balances');
$w = [ $w = [
['state', '!=', UserState::REJECTED] ['state', '!=', UserState::REJECTED],
]; ];
$users = $this->userRepo->findWhere($w, ['id', 'name', 'airline_id']); $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 * Figure out what flights need to be active for today
* @package App\Cron\Nightly
*/ */
class SetActiveFlights extends Listener class SetActiveFlights extends Listener
{ {
@ -38,7 +37,7 @@ class SetActiveFlights extends Listener
/** /**
* @var Flight $flight * @var Flight $flight
*/ */
foreach($flights as $flight) { foreach ($flights as $flight) {
if (!$flight->active) { if (!$flight->active) {
continue; continue;
} }
@ -73,8 +72,8 @@ class SetActiveFlights extends Listener
if ($today->gte($flight->start_date) && $today->lte($flight->end_date)) { if ($today->gte($flight->start_date) && $today->lte($flight->end_date)) {
if ($flight->days !== null && $flight->days > 0) { if ($flight->days !== null && $flight->days > 0) {
$visible = Days::isToday($flight->days); $visible = Days::isToday($flight->days);
if($flight->visible !== $visible) { if ($flight->visible !== $visible) {
Log::info('Toggling flight '.$flight->ident.' to '.($visible?'shown':'hidden').''); Log::info('Toggling flight '.$flight->ident.' to '.($visible ? 'shown' : 'hidden').'');
$flight->visible = $visible; $flight->visible = $visible;
if ($visible === false) { if ($visible === false) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,10 +8,10 @@ $factory->define(App\Models\JournalTransactions::class, function (Faker $faker)
'journal_id' => function () { 'journal_id' => function () {
return factory(App\Models\Journal::class)->create()->id; return factory(App\Models\Journal::class)->create()->id;
}, },
'credit' => $faker->numberBetween(100, 10000), 'credit' => $faker->numberBetween(100, 10000),
'debit' => $faker->numberBetween(100, 10000), 'debit' => $faker->numberBetween(100, 10000),
'currency' => 'USD', 'currency' => 'USD',
'memo' => $faker->sentence(6), 'memo' => $faker->sentence(6),
'post_date' => \Carbon\Carbon::now(), '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) { $factory->define(App\Models\News::class, function (Faker $faker) {
return [ return [
'id' => null, 'id' => null,
'user_id' => function() { 'user_id' => function () {
return factory(App\Models\User::class)->create()->id; return factory(App\Models\User::class)->create()->id;
}, },
'subject' => $faker->text(), 'subject' => $faker->text(),

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -13,7 +13,7 @@ class CreateNavdataTables extends Migration
*/ */
public function up() public function up()
{ {
/** /*
* See for defs, modify/update based on this * See for defs, modify/update based on this
* https://github.com/skiselkov/openfmc/blob/master/airac.h * 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('description')->nullable();
$table->text('image_url')->nullable(); $table->text('image_url')->nullable();
# ref fields are expenses tied to some model object // ref fields are expenses tied to some model object
# EG, the airports has an internal expense for gate costs // EG, the airports has an internal expense for gate costs
$table->string('ref_model')->nullable(); $table->string('ref_model')->nullable();
$table->text('ref_model_params')->nullable(); $table->text('ref_model_params')->nullable();
#$table->string('ref_model_id', 36)->nullable(); //$table->string('ref_model_id', 36)->nullable();
$table->timestamps(); $table->timestamps();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,6 @@ use Illuminate\Queue\SerializesModels;
/** /**
* Class UserRegistered * Class UserRegistered
* @package App\Events
*/ */
class UserRegistered class UserRegistered
{ {
@ -19,6 +18,7 @@ class UserRegistered
/** /**
* UserRegistered constructor. * UserRegistered constructor.
*
* @param User $user * @param User $user
*/ */
public function __construct(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 * Event triggered when a user's state changes
* @package App\Events
*/ */
class UserStateChanged class UserStateChanged
{ {
use Dispatchable, InteractsWithSockets, SerializesModels; use Dispatchable, InteractsWithSockets, SerializesModels;
public $old_state, $user; public $old_state;
public $user;
/** /**
* UserStateChanged constructor. * UserStateChanged constructor.
*
* @param User $user * @param User $user
* @param $old_state * @param $old_state
*/ */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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