Fix formatting and interfaces in nearly every file
This commit is contained in:
parent
04c5b9e7bf
commit
ccf56ddec1
27
.travis/Formatting.xml
Normal file
27
.travis/Formatting.xml
Normal file
@ -0,0 +1,27 @@
|
||||
<code_scheme name="PHPVMS" version="173">
|
||||
<option name="RIGHT_MARGIN" value="100" />
|
||||
<PHPCodeStyleSettings>
|
||||
<option name="ALIGN_KEY_VALUE_PAIRS" value="true" />
|
||||
<option name="LOWER_CASE_BOOLEAN_CONST" value="true" />
|
||||
<option name="LOWER_CASE_NULL_CONST" value="true" />
|
||||
<option name="ALIGN_CLASS_CONSTANTS" value="true" />
|
||||
<option name="FORCE_SHORT_DECLARATION_ARRAY_STYLE" value="true" />
|
||||
</PHPCodeStyleSettings>
|
||||
<XML>
|
||||
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
||||
</XML>
|
||||
<codeStyleSettings language="JAVA">
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="JSON">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="PHP">
|
||||
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
||||
<option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
@ -2,14 +2,14 @@
|
||||
|
||||
namespace App\Awards;
|
||||
|
||||
use App\Interfaces\AwardInterface;
|
||||
use App\Interfaces\Award;
|
||||
|
||||
/**
|
||||
* Simple example of an awards class, where you can apply an award when a user
|
||||
* has 100 flights. All award classes need to extend the AwardInterface
|
||||
* @package App\Awards
|
||||
*/
|
||||
class PilotFlightAwards extends AwardInterface
|
||||
class PilotFlightAwards extends Award
|
||||
{
|
||||
/**
|
||||
* Set the name of this award class to make it easier to see when
|
||||
@ -38,7 +38,7 @@ class PilotFlightAwards extends AwardInterface
|
||||
*/
|
||||
public function check($number_of_flights = null): bool
|
||||
{
|
||||
if(!$number_of_flights) {
|
||||
if (!$number_of_flights) {
|
||||
$number_of_flights = 100;
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,7 @@ class LoadConfiguration extends \Illuminate\Foundation\Bootstrap\LoadConfigurati
|
||||
* Load the configuration items from all of the files.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Foundation\Application $app
|
||||
* @param \Illuminate\Contracts\Config\Repository $repository
|
||||
* @return void
|
||||
* @param \Illuminate\Contracts\Config\Repository $repository
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function loadConfigurationFiles(Application $app, RepositoryContract $repository)
|
||||
|
@ -2,12 +2,20 @@
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Log;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class BaseCommand extends Command
|
||||
/**
|
||||
* Class BaseCommand
|
||||
* @package App\Console
|
||||
*/
|
||||
abstract class Command extends \Illuminate\Console\Command
|
||||
{
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function handle();
|
||||
|
||||
/**
|
||||
* Splice the logger and replace the active handlers with
|
||||
* the handlers from the "cron" stack in config/logging.php
|
||||
@ -17,7 +25,7 @@ class BaseCommand extends Command
|
||||
*
|
||||
* @param string $channel_name Channel name to grab the handlers from
|
||||
*/
|
||||
public function redirectLoggingToStdout($channel_name)
|
||||
public function redirectLoggingToStdout($channel_name): void
|
||||
{
|
||||
$logger = app(\Illuminate\Log\Logger::class);
|
||||
|
||||
@ -28,7 +36,7 @@ class BaseCommand extends Command
|
||||
$handler->close();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->error('Error closing handlers: ' . $e->getMessage());
|
||||
$this->error('Error closing handlers: '.$e->getMessage());
|
||||
}
|
||||
|
||||
// Open the handlers for the channel name,
|
||||
@ -38,7 +46,7 @@ class BaseCommand extends Command
|
||||
Log::channel($channel_name)->getHandlers()
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
$this->error('Couldn\'t splice the logger: ' . $e->getMessage());
|
||||
$this->error('Couldn\'t splice the logger: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,10 +55,9 @@ class BaseCommand extends Command
|
||||
* @param $filename
|
||||
* @return \Generator
|
||||
*/
|
||||
public function readFile($filename)
|
||||
public function readFile($filename): ?\Generator
|
||||
{
|
||||
$fp = fopen($filename, 'rb');
|
||||
|
||||
while (($line = fgets($fp)) !== false) {
|
||||
$line = rtrim($line, "\r\n");
|
||||
if ($line[0] === ';') {
|
||||
@ -64,20 +71,20 @@ class BaseCommand extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $cmd
|
||||
* @param $cmd
|
||||
* @param bool $return
|
||||
* @return string
|
||||
* @throws \Symfony\Component\Process\Exception\RuntimeException
|
||||
* @throws \Symfony\Component\Process\Exception\LogicException
|
||||
*/
|
||||
public function runCommand($cmd, $return = false, $verbose = true)
|
||||
public function runCommand($cmd, $return = false, $verbose = true): string
|
||||
{
|
||||
if (\is_array($cmd)) {
|
||||
$cmd = join(' ', $cmd);
|
||||
}
|
||||
|
||||
if ($verbose) {
|
||||
$this->info('Running "' . $cmd . '"');
|
||||
$this->info('Running "'.$cmd.'"');
|
||||
}
|
||||
|
||||
$val = '';
|
@ -2,12 +2,16 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\BaseCommand;
|
||||
use App\Console\Command;
|
||||
use App\Facades\Utils;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class AcarsReplay extends BaseCommand
|
||||
/**
|
||||
* Class AcarsReplay
|
||||
* @package App\Console\Commands
|
||||
*/
|
||||
class AcarsReplay extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:replay {files} {--manual} {--write-all} {--no-submit}';
|
||||
protected $description = 'Replay an ACARS file';
|
||||
@ -35,7 +39,6 @@ class AcarsReplay extends BaseCommand
|
||||
*/
|
||||
protected $httpClient;
|
||||
|
||||
|
||||
/**
|
||||
* Return an instance of an HTTP client all ready to post
|
||||
*/
|
||||
@ -45,46 +48,43 @@ class AcarsReplay extends BaseCommand
|
||||
|
||||
$this->httpClient = new Client([
|
||||
'base_uri' => config('app.url'),
|
||||
'headers' => [
|
||||
'headers' => [
|
||||
'Authorization' => $this->apiKey,
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/*protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['--files', InputOption::VALUE_OPTIONAL]
|
||||
];
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Make a request to start a PIREP
|
||||
* @param \stdClass $flight
|
||||
* @return string
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function startPirep($flight): string
|
||||
{
|
||||
# convert the planned flight time to be completely in minutes
|
||||
$pft = Utils::hoursToMinutes($flight->planned_hrsenroute,
|
||||
$flight->planned_minenroute);
|
||||
$pft = Utils::hoursToMinutes(
|
||||
$flight->planned_hrsenroute,
|
||||
$flight->planned_minenroute
|
||||
);
|
||||
|
||||
$flight_number = substr($flight->callsign, 3);
|
||||
|
||||
$response = $this->httpClient->post('/api/pireps/prefile', [
|
||||
'json' => [
|
||||
'airline_id' => 1,
|
||||
'flight_number' => $flight_number,
|
||||
'aircraft_id' => 1,
|
||||
'dpt_airport_id' => $flight->planned_depairport,
|
||||
'arr_airport_id' => $flight->planned_destairport,
|
||||
'level' => $flight->planned_altitude,
|
||||
'planned_flight_time' => $pft,
|
||||
'route' => $flight->planned_route,
|
||||
'airline_id' => 1,
|
||||
'flight_number' => $flight_number,
|
||||
'aircraft_id' => 1,
|
||||
'dpt_airport_id' => $flight->planned_depairport,
|
||||
'arr_airport_id' => $flight->planned_destairport,
|
||||
'level' => $flight->planned_altitude,
|
||||
'planned_flight_time' => $pft,
|
||||
'route' => $flight->planned_route,
|
||||
]
|
||||
]);
|
||||
|
||||
$body = \json_decode($response->getBody()->getContents());
|
||||
|
||||
return $body->id;
|
||||
}
|
||||
|
||||
@ -92,14 +92,16 @@ class AcarsReplay extends BaseCommand
|
||||
* Mark the PIREP as filed
|
||||
* @param $pirep_id
|
||||
* @return mixed
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function filePirep($pirep_id)
|
||||
{
|
||||
$response = $this->httpClient->post('/api/pireps/'.$pirep_id.'/file', [
|
||||
'json'=> []
|
||||
'json' => []
|
||||
]);
|
||||
|
||||
$body = \json_decode($response->getBody()->getContents());
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
@ -107,18 +109,19 @@ class AcarsReplay extends BaseCommand
|
||||
* @param $pirep_id
|
||||
* @param $data
|
||||
* @return array
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function postUpdate($pirep_id, $data)
|
||||
{
|
||||
$uri = '/api/pireps/' . $pirep_id . '/acars/position';
|
||||
$uri = '/api/pireps/'.$pirep_id.'/acars/position';
|
||||
|
||||
$position = [
|
||||
'log' => '',
|
||||
'lat' => $data->latitude,
|
||||
'lon' => $data->longitude,
|
||||
'heading' => $data->heading,
|
||||
'altitude' => $data->altitude,
|
||||
'gs' => $data->groundspeed,
|
||||
'log' => '',
|
||||
'lat' => $data->latitude,
|
||||
'lon' => $data->longitude,
|
||||
'heading' => $data->heading,
|
||||
'altitude' => $data->altitude,
|
||||
'gs' => $data->groundspeed,
|
||||
'transponder' => $data->transponder,
|
||||
];
|
||||
|
||||
@ -129,13 +132,14 @@ class AcarsReplay extends BaseCommand
|
||||
];
|
||||
|
||||
$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, [
|
||||
'json' => $upd
|
||||
]);
|
||||
|
||||
$body = \json_decode($response->getBody()->getContents());
|
||||
|
||||
return [
|
||||
$data->callsign,
|
||||
$position['lat'],
|
||||
@ -149,22 +153,24 @@ class AcarsReplay extends BaseCommand
|
||||
/**
|
||||
* Parse this file and run the updates
|
||||
* @param array $files
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function updatesFromFile(array $files)
|
||||
{
|
||||
/**
|
||||
* @var $flights Collection
|
||||
*/
|
||||
$flights = collect($files)->transform(function ($f)
|
||||
{
|
||||
$file = storage_path('/replay/' . $f . '.json');
|
||||
$flights = collect($files)->transform(function ($f) {
|
||||
$file = storage_path('/replay/'.$f.'.json');
|
||||
if (file_exists($file)) {
|
||||
$this->info('Loading ' . $file);
|
||||
$this->info('Loading '.$file);
|
||||
$contents = file_get_contents($file);
|
||||
$contents = \json_decode($contents);
|
||||
|
||||
return collect($contents->updates);
|
||||
} else {
|
||||
$this->error($file . ' not found, skipping');
|
||||
$this->error($file.' not found, skipping');
|
||||
|
||||
return false;
|
||||
}
|
||||
})
|
||||
@ -178,12 +184,11 @@ class AcarsReplay extends BaseCommand
|
||||
/**
|
||||
* File the initial pirep to get a "preflight" status
|
||||
*/
|
||||
$flights->each(function ($updates, $idx)
|
||||
{
|
||||
$flights->each(function ($updates, $idx) {
|
||||
$update = $updates->first();
|
||||
$pirep_id = $this->startPirep($update);
|
||||
$this->pirepList[$update->callsign] = $pirep_id;
|
||||
$this->info('Prefiled ' . $update->callsign . ', ID: ' . $pirep_id);
|
||||
$this->info('Prefiled '.$update->callsign.', ID: '.$pirep_id);
|
||||
});
|
||||
|
||||
/**
|
||||
@ -202,14 +207,14 @@ class AcarsReplay extends BaseCommand
|
||||
$this->postUpdate($pirep_id, $update);
|
||||
|
||||
# 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);
|
||||
}
|
||||
})->filter(function ($updates, $idx) {
|
||||
return $updates->count() > 0;
|
||||
});
|
||||
|
||||
if(!$this->option('write-all')) {
|
||||
if (!$this->option('write-all')) {
|
||||
if (!$this->option('manual')) {
|
||||
sleep($this->sleepTime);
|
||||
} else {
|
||||
@ -221,8 +226,8 @@ class AcarsReplay extends BaseCommand
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
@ -2,15 +2,22 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\BaseCommand;
|
||||
use App\Console\Command;
|
||||
use Log;
|
||||
|
||||
class CreateDatabase extends BaseCommand
|
||||
/**
|
||||
* Class CreateDatabase
|
||||
* @package App\Console\Commands
|
||||
*/
|
||||
class CreateDatabase extends Command
|
||||
{
|
||||
protected $signature = 'database:create {--reset} {--conn=?}';
|
||||
protected $description = 'Create a database';
|
||||
protected $os;
|
||||
|
||||
/**
|
||||
* CreateDatabase constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@ -24,21 +31,22 @@ class CreateDatabase extends BaseCommand
|
||||
*/
|
||||
protected function create_mysql($dbkey)
|
||||
{
|
||||
$host = config($dbkey . 'host');
|
||||
$port = config($dbkey . 'port');
|
||||
$name = config($dbkey . 'database');
|
||||
$user = config($dbkey . 'username');
|
||||
$pass = config($dbkey . 'password');
|
||||
$host = config($dbkey.'host');
|
||||
$port = config($dbkey.'port');
|
||||
$name = config($dbkey.'database');
|
||||
$user = config($dbkey.'username');
|
||||
$pass = config($dbkey.'password');
|
||||
|
||||
$dbSvc = new \App\Console\Services\Database();
|
||||
|
||||
$dsn = $dbSvc->createDsn($host, $port);
|
||||
Log::info('Connection string: ' . $dsn);
|
||||
Log::info('Connection string: '.$dsn);
|
||||
|
||||
try {
|
||||
$conn = $dbSvc->createPDO($dsn, $user, $pass);
|
||||
} catch (\PDOException $e) {
|
||||
Log::error($e);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -59,6 +67,7 @@ class CreateDatabase extends BaseCommand
|
||||
$conn->exec($sql);
|
||||
} catch (\PDOException $e) {
|
||||
Log::error($e);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -75,14 +84,14 @@ class CreateDatabase extends BaseCommand
|
||||
}
|
||||
|
||||
if ($this->option('reset') === true) {
|
||||
$cmd = ['rm', '-rf', config($dbkey . 'database')];
|
||||
$cmd = ['rm', '-rf', config($dbkey.'database')];
|
||||
$this->runCommand($cmd);
|
||||
}
|
||||
|
||||
if (!file_exists(config($dbkey . 'database'))) {
|
||||
if (!file_exists(config($dbkey.'database'))) {
|
||||
$cmd = [
|
||||
$exec,
|
||||
config($dbkey . 'database'),
|
||||
config($dbkey.'database'),
|
||||
'""',
|
||||
];
|
||||
|
||||
@ -108,21 +117,17 @@ class CreateDatabase extends BaseCommand
|
||||
}
|
||||
}*/
|
||||
|
||||
$this->info('Using connection "' . config('database.default') . '"');
|
||||
$this->info('Using connection "'.config('database.default').'"');
|
||||
|
||||
$conn = config('database.default');
|
||||
$dbkey = 'database.connections.' . $conn . '.';
|
||||
$dbkey = 'database.connections.'.$conn.'.';
|
||||
|
||||
if (config($dbkey . 'driver') === 'mysql') {
|
||||
if (config($dbkey.'driver') === 'mysql') {
|
||||
$this->create_mysql($dbkey);
|
||||
}
|
||||
|
||||
elseif (config($dbkey . 'driver') === 'sqlite') {
|
||||
} elseif (config($dbkey.'driver') === 'sqlite') {
|
||||
$this->create_sqlite($dbkey);
|
||||
}
|
||||
|
||||
// TODO: Eventually
|
||||
elseif (config($dbkey . 'driver') === 'postgres') {
|
||||
} // TODO: Eventually
|
||||
elseif (config($dbkey.'driver') === 'postgres') {
|
||||
$this->create_postgres($dbkey);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\BaseCommand;
|
||||
use App\Console\Command;
|
||||
use App\Models\Acars;
|
||||
use App\Models\Airline;
|
||||
use App\Models\Pirep;
|
||||
@ -12,7 +12,11 @@ use DB;
|
||||
use PDO;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class DevCommands extends BaseCommand
|
||||
/**
|
||||
* Class DevCommands
|
||||
* @package App\Console\Commands
|
||||
*/
|
||||
class DevCommands extends Command
|
||||
{
|
||||
protected $signature = 'phpvms {cmd} {param?}';
|
||||
protected $description = 'Developer commands';
|
||||
@ -30,15 +34,15 @@ class DevCommands extends BaseCommand
|
||||
}
|
||||
|
||||
$commands = [
|
||||
'list-awards' => 'listAwardClasses',
|
||||
'clear-acars' => 'clearAcars',
|
||||
'clear-users' => 'clearUsers',
|
||||
'compile-assets' => 'compileAssets',
|
||||
'db-attrs' => 'dbAttrs',
|
||||
'xml-to-yaml' => 'xmlToYaml',
|
||||
'list-awards' => 'listAwardClasses',
|
||||
'clear-acars' => 'clearAcars',
|
||||
'clear-users' => 'clearUsers',
|
||||
'compile-assets' => 'compileAssets',
|
||||
'db-attrs' => 'dbAttrs',
|
||||
'xml-to-yaml' => 'xmlToYaml',
|
||||
];
|
||||
|
||||
if(!array_key_exists($command, $commands)) {
|
||||
if (!array_key_exists($command, $commands)) {
|
||||
$this->error('Command not found!');
|
||||
exit();
|
||||
}
|
||||
@ -56,7 +60,7 @@ class DevCommands extends BaseCommand
|
||||
|
||||
$headers = ['Award Name', 'Class'];
|
||||
$formatted_awards = [];
|
||||
foreach($awards as $award) {
|
||||
foreach ($awards as $award) {
|
||||
$formatted_awards[] = [$award->name, \get_class($award)];
|
||||
}
|
||||
|
||||
@ -68,7 +72,7 @@ class DevCommands extends BaseCommand
|
||||
*/
|
||||
protected function clearAcars()
|
||||
{
|
||||
if(config('database.default') === 'mysql') {
|
||||
if (config('database.default') === 'mysql') {
|
||||
DB::statement('SET foreign_key_checks=0');
|
||||
}
|
||||
|
||||
@ -122,7 +126,7 @@ class DevCommands extends BaseCommand
|
||||
$server_version = $pdo->getAttribute(PDO::ATTR_SERVER_VERSION);
|
||||
$emulate_prepares = version_compare($server_version, $emulate_prepares_below_version, '<');
|
||||
|
||||
$this->info('Server Version: '. $server_version);
|
||||
$this->info('Server Version: '.$server_version);
|
||||
$this->info('Emulate Prepares: '.$emulate_prepares);
|
||||
|
||||
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, $emulate_prepares);
|
||||
@ -134,7 +138,7 @@ class DevCommands extends BaseCommand
|
||||
protected function xmlToYaml()
|
||||
{
|
||||
$file = $this->argument('param');
|
||||
$this->info('Reading '. $file);
|
||||
$this->info('Reading '.$file);
|
||||
|
||||
$xml_str = file_get_contents($file);
|
||||
$xml = new \SimpleXMLElement($xml_str);
|
||||
@ -148,7 +152,7 @@ class DevCommands extends BaseCommand
|
||||
|
||||
foreach ($xml->database->table_data->row as $row) {
|
||||
$yaml_row = [];
|
||||
foreach($row->field as $field) {
|
||||
foreach ($row->field as $field) {
|
||||
$fname = (string) $field['name'];
|
||||
$fvalue = (string) $field;
|
||||
|
||||
@ -163,6 +167,6 @@ class DevCommands extends BaseCommand
|
||||
|
||||
$file_name = $table_name.'.yml';
|
||||
file_put_contents(storage_path($file_name), Yaml::dump($yaml, 4, 2));
|
||||
$this->info('Writing yaml to storage: '. $file_name);
|
||||
$this->info('Writing yaml to storage: '.$file_name);
|
||||
}
|
||||
}
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\BaseCommand;
|
||||
use App\Console\Command;
|
||||
use Modules\Installer\Services\ConfigService;
|
||||
|
||||
/**
|
||||
* Create a fresh development install
|
||||
* @package App\Console\Commands
|
||||
*/
|
||||
class DevInstall extends BaseCommand
|
||||
class DevInstall extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:dev-install {--reset-db}';
|
||||
protected $description = 'Run a developer install and run the sample migration';
|
||||
@ -20,7 +20,7 @@ class DevInstall extends BaseCommand
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if(!$this->option('reset-db')) {
|
||||
if (!$this->option('reset-db')) {
|
||||
$this->rewriteConfigs();
|
||||
}
|
||||
|
||||
@ -69,26 +69,26 @@ class DevInstall extends BaseCommand
|
||||
|
||||
# Remove the old files
|
||||
$config_file = base_path('config.php');
|
||||
if(file_exists($config_file)) {
|
||||
if (file_exists($config_file)) {
|
||||
unlink($config_file);
|
||||
}
|
||||
|
||||
$env_file = base_path('env.php');
|
||||
if(file_exists($env_file)) {
|
||||
if (file_exists($env_file)) {
|
||||
unlink($env_file);
|
||||
}
|
||||
|
||||
$this->info('Removing the sqlite db');
|
||||
$db_file = storage_path('db.sqlite');
|
||||
if(file_exists($db_file)) {
|
||||
if (file_exists($db_file)) {
|
||||
unlink($db_file);
|
||||
}
|
||||
|
||||
$this->info('Regenerating the config files');
|
||||
$cfgSvc->createConfigFiles([
|
||||
'APP_ENV' => 'dev',
|
||||
'APP_ENV' => 'dev',
|
||||
'SITE_NAME' => 'phpvms test',
|
||||
'DB_CONN' => 'sqlite',
|
||||
'DB_CONN' => 'sqlite',
|
||||
]);
|
||||
|
||||
$this->info('Config files generated!');
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\BaseCommand;
|
||||
use App\Console\Command;
|
||||
|
||||
class ImportFromClassic extends BaseCommand
|
||||
class ImportFromClassic extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:importer {db_host} {db_name} {db_user} {db_pass?} {table_prefix=phpvms_}';
|
||||
protected $description = 'Import from an older version of phpVMS';
|
||||
@ -15,10 +15,10 @@ class ImportFromClassic extends BaseCommand
|
||||
public function handle()
|
||||
{
|
||||
$db_creds = [
|
||||
'host' => $this->argument('db_host'),
|
||||
'name' => $this->argument('db_name'),
|
||||
'user' => $this->argument('db_user'),
|
||||
'pass' => $this->argument('db_pass'),
|
||||
'host' => $this->argument('db_host'),
|
||||
'name' => $this->argument('db_name'),
|
||||
'user' => $this->argument('db_user'),
|
||||
'pass' => $this->argument('db_pass'),
|
||||
'table_prefix' => $this->argument('table_prefix')
|
||||
];
|
||||
|
||||
|
@ -2,9 +2,13 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\BaseCommand;
|
||||
use App\Console\Command;
|
||||
|
||||
class Install extends BaseCommand
|
||||
/**
|
||||
* Class Install
|
||||
* @package App\Console\Commands
|
||||
*/
|
||||
class Install extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:install
|
||||
{--update}
|
||||
@ -13,11 +17,17 @@ class Install extends BaseCommand
|
||||
|
||||
protected $description = 'Install or update phpVMS';
|
||||
|
||||
/**
|
||||
* Install constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Installing phpVMS...');
|
||||
@ -25,7 +35,7 @@ class Install extends BaseCommand
|
||||
$this->setupDatabase();
|
||||
|
||||
# Only run these if we're doing an initial install
|
||||
if(!$this->option('update')) {
|
||||
if (!$this->option('update')) {
|
||||
$this->writeLocalConfig();
|
||||
$this->initialData();
|
||||
}
|
||||
@ -38,22 +48,20 @@ class Install extends BaseCommand
|
||||
*/
|
||||
protected function setupDatabase()
|
||||
{
|
||||
if(!$this->option('update')) {
|
||||
if (!$this->option('update')) {
|
||||
$this->call('database:create');
|
||||
}
|
||||
|
||||
$this->info('Running database migrations...');
|
||||
$this->call('migrate');
|
||||
|
||||
# TODO: Call initial seed data, for the groups and other supporting data
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a local config file
|
||||
*/
|
||||
protected function writeLocalConfig()
|
||||
protected function writeLocalConfig(): void
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,15 +71,14 @@ class Install extends BaseCommand
|
||||
{
|
||||
# TODO: Prompt for initial airline info
|
||||
$airline_name = $this->option('airline-name');
|
||||
if(!$airline_name) {
|
||||
if (!$airline_name) {
|
||||
$airline_name = $this->ask('Enter your airline name');
|
||||
}
|
||||
|
||||
$airline_code = $this->option('airline-code');
|
||||
if(!$airline_code) {
|
||||
if (!$airline_code) {
|
||||
$airline_code = $this->ask('Enter your airline code');
|
||||
}
|
||||
|
||||
# TODO: Prompt for admin user/password
|
||||
}
|
||||
}
|
||||
|
@ -2,15 +2,33 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\BaseCommand;
|
||||
use App\Console\Command;
|
||||
use App\Models\Enums\NavaidType;
|
||||
use App\Models\Navdata;
|
||||
|
||||
class NavdataImport extends BaseCommand
|
||||
/**
|
||||
* Class NavdataImport
|
||||
* @package App\Console\Commands
|
||||
*/
|
||||
class NavdataImport extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:navdata';
|
||||
protected $description = '';
|
||||
|
||||
/**
|
||||
* @return mixed|void
|
||||
* @throws \League\Geotools\Exception\InvalidArgumentException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Emptying the current navdata...');
|
||||
Navdata::query()->truncate();
|
||||
|
||||
$this->info('Looking for nav files...');
|
||||
$this->read_wp_nav_aid();
|
||||
$this->read_wp_nav_fix();
|
||||
}
|
||||
|
||||
/**
|
||||
* Read and parse in the navaid file
|
||||
* @throws \League\Geotools\Exception\InvalidArgumentException
|
||||
@ -49,6 +67,7 @@ class NavdataImport extends BaseCommand
|
||||
$file_path = storage_path('/navdata/WPNAVAID.txt');
|
||||
if (!file_exists($file_path)) {
|
||||
$this->error('WPNAVAID.txt not found in storage/navdata');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -57,10 +76,9 @@ class NavdataImport extends BaseCommand
|
||||
|
||||
$imported = 0;
|
||||
|
||||
foreach($generator as $line) {
|
||||
|
||||
foreach ($generator as $line) {
|
||||
$navaid = [
|
||||
'id' => trim(substr($line, 24, 4)), // ident column
|
||||
'id' => trim(substr($line, 24, 4)), // ident column
|
||||
'name' => trim(substr($line, 0, 24)),
|
||||
'type' => trim(substr($line, 29, 4)),
|
||||
'lat' => trim(substr($line, 33, 9)),
|
||||
@ -70,8 +88,7 @@ class NavdataImport extends BaseCommand
|
||||
];
|
||||
|
||||
# Map to the Navaid enum
|
||||
switch($navaid['type'])
|
||||
{
|
||||
switch ($navaid['type']) {
|
||||
case 'ILS':
|
||||
$navaid['type'] = NavaidType::LOC;
|
||||
break;
|
||||
@ -104,12 +121,12 @@ class NavdataImport extends BaseCommand
|
||||
], $navaid);
|
||||
|
||||
$imported++;
|
||||
if($imported % 100 === 0) {
|
||||
$this->info('Imported ' . $imported . ' entries...');
|
||||
if ($imported % 100 === 0) {
|
||||
$this->info('Imported '.$imported.' entries...');
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Imported a total of ' . $imported . ' nav aids');
|
||||
$this->info('Imported a total of '.$imported.' nav aids');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -137,8 +154,9 @@ class NavdataImport extends BaseCommand
|
||||
*/
|
||||
|
||||
$file_path = storage_path('/navdata/WPNAVFIX.txt');
|
||||
if(!file_exists($file_path)) {
|
||||
if (!file_exists($file_path)) {
|
||||
$this->error('WPNAVFIX.txt not found in storage/navdata');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -148,11 +166,11 @@ class NavdataImport extends BaseCommand
|
||||
$imported = 0;
|
||||
foreach ($generator as $line) {
|
||||
$navfix = [
|
||||
'id' => trim(substr($line, 0, 4)), // ident column
|
||||
'id' => trim(substr($line, 0, 4)), // ident column
|
||||
'name' => trim(substr($line, 24, 6)),
|
||||
'type' => NavaidType::FIX,
|
||||
'lat' => trim(substr($line, 30, 10)),
|
||||
'lon' => trim(substr($line, 40, 11)),
|
||||
'lat' => trim(substr($line, 30, 10)),
|
||||
'lon' => trim(substr($line, 40, 11)),
|
||||
];
|
||||
|
||||
switch ($navfix['type']) {
|
||||
@ -165,20 +183,10 @@ class NavdataImport extends BaseCommand
|
||||
|
||||
$imported++;
|
||||
if ($imported % 100 === 0) {
|
||||
$this->info('Imported ' . $imported . ' entries...');
|
||||
$this->info('Imported '.$imported.' entries...');
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Imported a total of ' . $imported . ' nav fixes');
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Emptying the current navdata...');
|
||||
Navdata::query()->truncate();
|
||||
|
||||
$this->info('Looking for nav files...');
|
||||
$this->read_wp_nav_aid();
|
||||
$this->read_wp_nav_fix();
|
||||
$this->info('Imported a total of '.$imported.' nav fixes');
|
||||
}
|
||||
}
|
||||
|
@ -2,13 +2,16 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\BaseCommand;
|
||||
use App\Console\Command;
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
class TestApi extends BaseCommand
|
||||
/**
|
||||
* Class TestApi
|
||||
* @package App\Console\Commands
|
||||
*/
|
||||
class TestApi extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:test-api {apikey} {url}';
|
||||
|
||||
protected $httpClient;
|
||||
|
||||
/**
|
||||
@ -17,11 +20,11 @@ class TestApi extends BaseCommand
|
||||
public function handle()
|
||||
{
|
||||
$this->httpClient = new Client([
|
||||
'headers' => [
|
||||
'Authorization' => $this->argument('apikey'),
|
||||
'Content-type' => 'application/json',
|
||||
'X-API-Key' => $this->argument('apikey'),
|
||||
]
|
||||
'headers' => [
|
||||
'Authorization' => $this->argument('apikey'),
|
||||
'Content-type' => 'application/json',
|
||||
'X-API-Key' => $this->argument('apikey'),
|
||||
]
|
||||
]);
|
||||
|
||||
$result = $this->httpClient->get($this->argument('url'));
|
||||
|
@ -2,10 +2,14 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\BaseCommand;
|
||||
use App\Console\Command;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class Version extends BaseCommand
|
||||
/**
|
||||
* Class Version
|
||||
* @package App\Console\Commands
|
||||
*/
|
||||
class Version extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:version {--write} {--base-only}';
|
||||
|
||||
@ -19,7 +23,7 @@ class Version extends BaseCommand
|
||||
|
||||
# prefix with the date in YYMMDD format
|
||||
$date = date('ymd');
|
||||
$version = $date . '-' . $version;
|
||||
$version = $date.'-'.$version;
|
||||
|
||||
return $version;
|
||||
}
|
||||
@ -46,11 +50,11 @@ class Version extends BaseCommand
|
||||
|
||||
# Only show the major.minor.patch version
|
||||
if ($this->option('base-only')) {
|
||||
$version = 'v' . $cfg['current']['major'] . '.'
|
||||
. $cfg['current']['minor'] . '.'
|
||||
. $cfg['current']['patch'];
|
||||
$version = 'v'.$cfg['current']['major'].'.'
|
||||
.$cfg['current']['minor'].'.'
|
||||
.$cfg['current']['patch'];
|
||||
}
|
||||
|
||||
print $version . "\n";
|
||||
print $version."\n";
|
||||
}
|
||||
}
|
||||
|
@ -2,16 +2,24 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\BaseCommand;
|
||||
use App\Console\Command;
|
||||
use App\Services\DatabaseService;
|
||||
use DB;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class YamlExport extends BaseCommand
|
||||
/**
|
||||
* Class YamlExport
|
||||
* @package App\Console\Commands
|
||||
*/
|
||||
class YamlExport extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:export {tables*}';
|
||||
protected $description = 'YAML table export';
|
||||
|
||||
/**
|
||||
* YamlExport constructor.
|
||||
* @param DatabaseService $dbSvc
|
||||
*/
|
||||
public function __construct(DatabaseService $dbSvc)
|
||||
{
|
||||
parent::__construct();
|
||||
@ -23,17 +31,17 @@ class YamlExport extends BaseCommand
|
||||
public function handle()
|
||||
{
|
||||
$tables = $this->argument('tables');
|
||||
if(empty($tables)) {
|
||||
if (empty($tables)) {
|
||||
$this->error('No tables specified');
|
||||
exit();
|
||||
}
|
||||
|
||||
$export_tables = [];
|
||||
foreach($tables as $table) {
|
||||
foreach ($tables as $table) {
|
||||
$export_tables[$table] = [];
|
||||
|
||||
$rows = DB::table($table)->get();
|
||||
foreach($rows as $row) {
|
||||
foreach ($rows as $row) {
|
||||
$export_tables[$table][] = (array) $row;
|
||||
}
|
||||
}
|
||||
|
@ -2,16 +2,23 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\BaseCommand;
|
||||
use App\Console\Command;
|
||||
use App\Services\DatabaseService;
|
||||
|
||||
class YamlImport extends BaseCommand
|
||||
/**
|
||||
* Class YamlImport
|
||||
* @package App\Console\Commands
|
||||
*/
|
||||
class YamlImport extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:import {files*}';
|
||||
protected $description = 'Developer commands';
|
||||
|
||||
protected $dbSvc;
|
||||
|
||||
/**
|
||||
* YamlImport constructor.
|
||||
* @param DatabaseService $dbSvc
|
||||
*/
|
||||
public function __construct(DatabaseService $dbSvc)
|
||||
{
|
||||
parent::__construct();
|
||||
@ -20,31 +27,28 @@ class YamlImport extends BaseCommand
|
||||
|
||||
/**
|
||||
* Run dev related commands
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$files = $this->argument('files');
|
||||
if(empty($files)) {
|
||||
if (empty($files)) {
|
||||
$this->error('No files to import specified!');
|
||||
exit();
|
||||
}
|
||||
|
||||
$ignore_errors = true;
|
||||
/*$ignore_errors = $this->option('ignore_errors');
|
||||
if(!$ignore_errors) {
|
||||
$ignore_errors = false;
|
||||
}*/
|
||||
|
||||
foreach($files as $file) {
|
||||
if(!file_exists($file)) {
|
||||
$this->error('File ' . $file .' doesn\'t exist');
|
||||
foreach ($files as $file) {
|
||||
if (!file_exists($file)) {
|
||||
$this->error('File '.$file.' doesn\'t exist');
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->info('Importing ' . $file);
|
||||
$this->info('Importing '.$file);
|
||||
|
||||
$imported = $this->dbSvc->seed_from_yaml_file($file, $ignore_errors);
|
||||
foreach($imported as $table => $count) {
|
||||
foreach ($imported as $table => $count) {
|
||||
$this->info('Imported '.$count.' records from "'.$table.'"');
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Console\Cron;
|
||||
|
||||
use App\Console\BaseCommand;
|
||||
use App\Console\Command;
|
||||
use App\Events\CronMonthly;
|
||||
|
||||
/**
|
||||
@ -10,12 +10,15 @@ use App\Events\CronMonthly;
|
||||
* listeners, etc can just be called to run those tasks
|
||||
* @package App\Console\Cron
|
||||
*/
|
||||
class Monthly extends BaseCommand
|
||||
class Monthly extends Command
|
||||
{
|
||||
protected $signature = 'cron:monthly';
|
||||
protected $description = 'Run the monthly cron tasks';
|
||||
protected $schedule;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$this->redirectLoggingToStdout('cron');
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Console\Cron;
|
||||
|
||||
use App\Console\BaseCommand;
|
||||
use App\Console\Command;
|
||||
use App\Events\CronNightly;
|
||||
|
||||
/**
|
||||
@ -10,12 +10,15 @@ use App\Events\CronNightly;
|
||||
* listeners, etc can just be called to run those tasks
|
||||
* @package App\Console\Cron
|
||||
*/
|
||||
class Nightly extends BaseCommand
|
||||
class Nightly extends Command
|
||||
{
|
||||
protected $signature = 'cron:nightly';
|
||||
protected $description = 'Run the nightly cron tasks';
|
||||
protected $schedule;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$this->redirectLoggingToStdout('cron');
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Console\Cron;
|
||||
|
||||
use App\Console\BaseCommand;
|
||||
use App\Console\Command;
|
||||
use App\Events\CronMonthly;
|
||||
|
||||
/**
|
||||
@ -10,12 +10,15 @@ use App\Events\CronMonthly;
|
||||
* listeners, etc can just be called to run those tasks
|
||||
* @package App\Console\Cron
|
||||
*/
|
||||
class Weekly extends BaseCommand
|
||||
class Weekly extends Command
|
||||
{
|
||||
protected $signature = 'cron:monthly';
|
||||
protected $description = 'Run the monthly cron tasks';
|
||||
protected $schedule;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$this->redirectLoggingToStdout('cron');
|
||||
|
@ -8,13 +8,12 @@ use App\Console\Cron\Weekly;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
/**
|
||||
* Class Kernel
|
||||
* @package App\Console
|
||||
*/
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
Commands\AcarsReplay::class,
|
||||
Commands\CreateDatabase::class,
|
||||
@ -28,7 +27,7 @@ class Kernel extends ConsoleKernel
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule): void
|
||||
@ -45,7 +44,7 @@ class Kernel extends ConsoleKernel
|
||||
protected function commands(): void
|
||||
{
|
||||
require app_path('Routes/console.php');
|
||||
$this->load(__DIR__ . '/Commands');
|
||||
$this->load(__DIR__ . '/Cron');
|
||||
$this->load(__DIR__.'/Commands');
|
||||
$this->load(__DIR__.'/Cron');
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Console\Services;
|
||||
|
||||
use Doctrine\DBAL\Driver\PDOException;
|
||||
use PDOException;
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
@ -13,16 +13,16 @@ class Database
|
||||
{
|
||||
/**
|
||||
* Create the base connection DSN, optionally include the DB name
|
||||
* @param $host
|
||||
* @param $port
|
||||
* @param $host
|
||||
* @param $port
|
||||
* @param null $name
|
||||
* @return string
|
||||
*/
|
||||
public function createDsn($host, $port, $name=null)
|
||||
public function createDsn($host, $port, $name = null)
|
||||
{
|
||||
$conn = config('database.default');
|
||||
$dsn = "$conn:host=$host;port=$port";
|
||||
if(filled($name)) {
|
||||
if (filled($name)) {
|
||||
$dsn .= ';dbname='.$name;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ use App\Models\Rank;
|
||||
use App\Models\Subfleet;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Doctrine\DBAL\Driver\PDOException;
|
||||
use PDOException;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
@ -56,7 +56,7 @@ class Importer
|
||||
*/
|
||||
|
||||
const BATCH_READ_ROWS = 300;
|
||||
const SUBFLEET_NAME = 'Imported Aircraft';
|
||||
const SUBFLEET_NAME = 'Imported Aircraft';
|
||||
|
||||
/**
|
||||
* Importer constructor.
|
||||
@ -69,11 +69,11 @@ class Importer
|
||||
|
||||
# The db credentials
|
||||
$this->creds = array_merge([
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 3306,
|
||||
'name' => '',
|
||||
'user' => '',
|
||||
'pass' => '',
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 3306,
|
||||
'name' => '',
|
||||
'user' => '',
|
||||
'pass' => '',
|
||||
'table_prefix' => 'phpvms_'
|
||||
], $db_creds);
|
||||
}
|
||||
@ -105,13 +105,13 @@ class Importer
|
||||
*/
|
||||
protected function reconnect()
|
||||
{
|
||||
$dsn = 'mysql:' . implode(';', [
|
||||
'host=' . $this->creds['host'],
|
||||
'port=' . $this->creds['port'],
|
||||
'dbname=' . $this->creds['name']
|
||||
$dsn = 'mysql:'.implode(';', [
|
||||
'host='.$this->creds['host'],
|
||||
'port='.$this->creds['port'],
|
||||
'dbname='.$this->creds['name']
|
||||
]);
|
||||
|
||||
$this->info('Connection string: ' . $dsn);
|
||||
$this->info('Connection string: '.$dsn);
|
||||
|
||||
try {
|
||||
$this->conn = new PDO($dsn, $this->creds['user'], $this->creds['pass']);
|
||||
@ -127,14 +127,15 @@ class Importer
|
||||
*/
|
||||
protected function comment($message)
|
||||
{
|
||||
$this->log->writeln('<comment>' . $message . '</comment>');
|
||||
$this->log->writeln('<comment>'.$message.'</comment>');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $message
|
||||
*/
|
||||
protected function error($message) {
|
||||
$this->log->writeln('<error>' . $message . '</error>');
|
||||
protected function error($message)
|
||||
{
|
||||
$this->log->writeln('<error>'.$message.'</error>');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -142,10 +143,9 @@ class Importer
|
||||
*/
|
||||
protected function info($message)
|
||||
{
|
||||
if(\is_array($message)) {
|
||||
if (\is_array($message)) {
|
||||
print_r($message);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->log->writeln('<info>'.$message.'</info>');
|
||||
}
|
||||
}
|
||||
@ -157,7 +157,7 @@ class Importer
|
||||
*/
|
||||
protected function tableName($table)
|
||||
{
|
||||
if($this->creds['table_prefix'] !== false) {
|
||||
if ($this->creds['table_prefix'] !== false) {
|
||||
return $this->creds['table_prefix'].$table;
|
||||
}
|
||||
|
||||
@ -173,9 +173,10 @@ class Importer
|
||||
{
|
||||
try {
|
||||
$model->save();
|
||||
|
||||
return true;
|
||||
} catch (QueryException $e) {
|
||||
if($e->getCode() !== '23000') {
|
||||
if ($e->getCode() !== '23000') {
|
||||
$this->error($e);
|
||||
}
|
||||
|
||||
@ -191,7 +192,7 @@ class Importer
|
||||
*/
|
||||
protected function addMapping($entity, $old_id, $new_id)
|
||||
{
|
||||
if(!array_key_exists($entity, $this->mappedEntities)) {
|
||||
if (!array_key_exists($entity, $this->mappedEntities)) {
|
||||
$this->mappedEntities[$entity] = [];
|
||||
}
|
||||
|
||||
@ -206,12 +207,12 @@ class Importer
|
||||
*/
|
||||
protected function getMapping($entity, $old_id)
|
||||
{
|
||||
if(!array_key_exists($entity, $this->mappedEntities)) {
|
||||
if (!array_key_exists($entity, $this->mappedEntities)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$entity = $this->mappedEntities[$entity];
|
||||
if(array_key_exists($old_id, $entity)) {
|
||||
if (array_key_exists($old_id, $entity)) {
|
||||
return $entity[$old_id];
|
||||
}
|
||||
|
||||
@ -225,6 +226,7 @@ class Importer
|
||||
protected function parseDate($date)
|
||||
{
|
||||
$carbon = Carbon::parse($date);
|
||||
|
||||
return $carbon;
|
||||
}
|
||||
|
||||
@ -235,9 +237,9 @@ class Importer
|
||||
*/
|
||||
protected function convertDuration($duration)
|
||||
{
|
||||
if(strpos($duration, '.') !== false) {
|
||||
if (strpos($duration, '.') !== false) {
|
||||
$delim = '.';
|
||||
} elseif(strpos($duration, ':')) {
|
||||
} elseif (strpos($duration, ':')) {
|
||||
$delim = ':';
|
||||
} else {
|
||||
# no delimiter, assume it's just a straight hour
|
||||
@ -259,52 +261,52 @@ class Importer
|
||||
{
|
||||
$table = $this->tableName($table);
|
||||
|
||||
$sql = 'SELECT COUNT(*) FROM ' . $table;
|
||||
$sql = 'SELECT COUNT(*) FROM '.$table;
|
||||
$rows = $this->conn->query($sql)->fetchColumn();
|
||||
|
||||
$this->info('Found '.$rows.' rows in '.$table);
|
||||
|
||||
return (int) $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read all the rows in a table, but read them in a batched manner
|
||||
* @param string $table The name of the table
|
||||
* @param null $read_rows Number of rows to read
|
||||
* @param string $table The name of the table
|
||||
* @param null $read_rows Number of rows to read
|
||||
* @return \Generator
|
||||
*/
|
||||
protected function readRows($table, $read_rows=null)
|
||||
protected function readRows($table, $read_rows = null)
|
||||
{
|
||||
// Set the table prefix if it has been entered
|
||||
$this->tableName($table);
|
||||
|
||||
$offset = 0;
|
||||
if($read_rows === null) {
|
||||
if ($read_rows === null) {
|
||||
$read_rows = self::BATCH_READ_ROWS;
|
||||
}
|
||||
|
||||
$total_rows = $this->getTotalRows($table);
|
||||
|
||||
while($offset < $total_rows)
|
||||
{
|
||||
while ($offset < $total_rows) {
|
||||
$rows_to_read = $offset + $read_rows;
|
||||
if($rows_to_read > $total_rows) {
|
||||
if ($rows_to_read > $total_rows) {
|
||||
$rows_to_read = $total_rows;
|
||||
}
|
||||
|
||||
$this->info('Reading '.$offset.' to '.$rows_to_read.' of '.$total_rows);
|
||||
|
||||
$sql = 'SELECT * FROM ' . $this->tableName($table)
|
||||
. ' LIMIT ' . self::BATCH_READ_ROWS . ' OFFSET ' . $offset;
|
||||
$sql = 'SELECT * FROM '.$this->tableName($table)
|
||||
.' LIMIT '.self::BATCH_READ_ROWS.' OFFSET '.$offset;
|
||||
|
||||
try {
|
||||
foreach ($this->conn->query($sql) as $row) {
|
||||
yield $row;
|
||||
}
|
||||
} catch(PDOException $e) {
|
||||
} catch (PDOException $e) {
|
||||
// Without incrementing the offset, it should re-run the same query
|
||||
$this->error($e);
|
||||
|
||||
if(strpos($e->getMessage(), 'server has gone away') !== false) {
|
||||
if (strpos($e->getMessage(), 'server has gone away') !== false) {
|
||||
$this->reconnect();
|
||||
continue;
|
||||
}
|
||||
@ -344,22 +346,21 @@ class Importer
|
||||
$this->comment('--- RANK IMPORT ---');
|
||||
|
||||
$count = 0;
|
||||
foreach ($this->readRows('ranks') as $row)
|
||||
{
|
||||
foreach ($this->readRows('ranks') as $row) {
|
||||
$rank = Rank::firstOrCreate(
|
||||
['name' => $row->rank],
|
||||
['image_url' => $row->rankimage, 'hours'=>$row->minhours]
|
||||
['image_url' => $row->rankimage, 'hours' => $row->minhours]
|
||||
);
|
||||
|
||||
$this->addMapping('ranks', $row->rankid, $rank->id);
|
||||
$this->addMapping('ranks', $row->rank, $rank->id);
|
||||
|
||||
if($rank->wasRecentlyCreated) {
|
||||
if ($rank->wasRecentlyCreated) {
|
||||
++$count;
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Imported ' . $count . ' ranks');
|
||||
$this->info('Imported '.$count.' ranks');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -371,8 +372,7 @@ class Importer
|
||||
$this->comment('--- AIRLINE IMPORT ---');
|
||||
|
||||
$count = 0;
|
||||
foreach ($this->readRows('airlines') as $row)
|
||||
{
|
||||
foreach ($this->readRows('airlines') as $row) {
|
||||
$airline = Airline::firstOrCreate(
|
||||
['icao' => $row->code],
|
||||
['iata' => $row->code, 'name' => $row->name, 'active' => $row->enabled]
|
||||
@ -386,7 +386,7 @@ class Importer
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Imported '. $count.' airlines');
|
||||
$this->info('Imported '.$count.' airlines');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -401,23 +401,22 @@ class Importer
|
||||
$this->info('Subfleet ID is '.$subfleet->id);
|
||||
|
||||
$count = 0;
|
||||
foreach($this->readRows('aircraft') as $row)
|
||||
{
|
||||
foreach ($this->readRows('aircraft') as $row) {
|
||||
$aircraft = Aircraft::firstOrCreate(
|
||||
['name' => $row->fullname, 'registration' => $row->registration],
|
||||
['icao' => $row->icao,
|
||||
['icao' => $row->icao,
|
||||
'subfleet_id' => $subfleet->id,
|
||||
'active' => $row->enabled
|
||||
'active' => $row->enabled
|
||||
]);
|
||||
|
||||
$this->addMapping('aircraft', $row->id, $aircraft->id);
|
||||
|
||||
if($aircraft->wasRecentlyCreated) {
|
||||
if ($aircraft->wasRecentlyCreated) {
|
||||
++$count;
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Imported ' . $count . ' aircraft');
|
||||
$this->info('Imported '.$count.' aircraft');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -428,16 +427,15 @@ class Importer
|
||||
$this->comment('--- AIRPORT IMPORT ---');
|
||||
|
||||
$count = 0;
|
||||
foreach ($this->readRows('airports') as $row)
|
||||
{
|
||||
foreach ($this->readRows('airports') as $row) {
|
||||
$attrs = [
|
||||
'id' => trim($row->icao),
|
||||
'icao' => trim($row->icao),
|
||||
'name' => $row->name,
|
||||
'id' => trim($row->icao),
|
||||
'icao' => trim($row->icao),
|
||||
'name' => $row->name,
|
||||
'country' => $row->country,
|
||||
'lat' => $row->lat,
|
||||
'lon' => $row->lng,
|
||||
'hub' => $row->hub,
|
||||
'lat' => $row->lat,
|
||||
'lon' => $row->lng,
|
||||
'hub' => $row->hub,
|
||||
];
|
||||
|
||||
$airport = Airport::updateOrCreate(
|
||||
@ -445,12 +443,12 @@ class Importer
|
||||
$attrs
|
||||
);
|
||||
|
||||
if($airport->wasRecentlyCreated) {
|
||||
if ($airport->wasRecentlyCreated) {
|
||||
++$count;
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Imported ' . $count . ' airports');
|
||||
$this->info('Imported '.$count.' airports');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -461,8 +459,7 @@ class Importer
|
||||
$this->comment('--- FLIGHT SCHEDULE IMPORT ---');
|
||||
|
||||
$count = 0;
|
||||
foreach ($this->readRows('schedules') as $row)
|
||||
{
|
||||
foreach ($this->readRows('schedules') as $row) {
|
||||
$airline_id = $this->getMapping('airlines', $row->code);
|
||||
|
||||
$flight_num = trim($row->flightnum);
|
||||
@ -470,14 +467,14 @@ class Importer
|
||||
$attrs = [
|
||||
'dpt_airport_id' => $row->depicao,
|
||||
'arr_airport_id' => $row->arricao,
|
||||
'route' => $row->route ?: '',
|
||||
'distance' => round($row->distance ?: 0, 2),
|
||||
'level' => $row->flightlevel ?: 0,
|
||||
'dpt_time' => $row->deptime ?: '',
|
||||
'arr_time' => $row->arrtime ?: '',
|
||||
'flight_time' => $this->convertDuration($row->flighttime) ?: '',
|
||||
'notes' => $row->notes ?: '',
|
||||
'active' => $row->enabled ?: true,
|
||||
'route' => $row->route ?: '',
|
||||
'distance' => round($row->distance ?: 0, 2),
|
||||
'level' => $row->flightlevel ?: 0,
|
||||
'dpt_time' => $row->deptime ?: '',
|
||||
'arr_time' => $row->arrtime ?: '',
|
||||
'flight_time' => $this->convertDuration($row->flighttime) ?: '',
|
||||
'notes' => $row->notes ?: '',
|
||||
'active' => $row->enabled ?: true,
|
||||
];
|
||||
|
||||
try {
|
||||
@ -493,12 +490,12 @@ class Importer
|
||||
|
||||
// TODO: deserialize route_details into ACARS table
|
||||
|
||||
if($flight->wasRecentlyCreated) {
|
||||
if ($flight->wasRecentlyCreated) {
|
||||
++$count;
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Imported ' . $count . ' flights');
|
||||
$this->info('Imported '.$count.' flights');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -509,8 +506,7 @@ class Importer
|
||||
$this->comment('--- PIREP IMPORT ---');
|
||||
|
||||
$count = 0;
|
||||
foreach ($this->readRows('pireps') as $row)
|
||||
{
|
||||
foreach ($this->readRows('pireps') as $row) {
|
||||
$pirep_id = $row->pirepid;
|
||||
$user_id = $this->getMapping('users', $row->pilotid);
|
||||
$airline_id = $this->getMapping('airlines', $row->code);
|
||||
@ -518,17 +514,17 @@ class Importer
|
||||
|
||||
$attrs = [
|
||||
#'id' => $pirep_id,
|
||||
'user_id' => $user_id,
|
||||
'airline_id' => $airline_id,
|
||||
'aircraft_id' => $aircraft_id,
|
||||
'flight_number' => $row->flightnum ?: '',
|
||||
'user_id' => $user_id,
|
||||
'airline_id' => $airline_id,
|
||||
'aircraft_id' => $aircraft_id,
|
||||
'flight_number' => $row->flightnum ?: '',
|
||||
'dpt_airport_id' => $row->depicao,
|
||||
'arr_airport_id' => $row->arricao,
|
||||
'block_fuel' => $row->fuelused,
|
||||
'route' => $row->route ?: '',
|
||||
'source_name' => $row->source,
|
||||
'created_at' => $this->parseDate($row->submitdate),
|
||||
'updated_at' => $this->parseDate($row->modifieddate),
|
||||
'block_fuel' => $row->fuelused,
|
||||
'route' => $row->route ?: '',
|
||||
'source_name' => $row->source,
|
||||
'created_at' => $this->parseDate($row->submitdate),
|
||||
'updated_at' => $this->parseDate($row->modifieddate),
|
||||
];
|
||||
|
||||
# Set the distance
|
||||
@ -542,7 +538,7 @@ class Importer
|
||||
$attrs['planned_flight_time'] = $duration;
|
||||
|
||||
# Set how it was filed
|
||||
if(strtoupper($row->source) === 'MANUAL') {
|
||||
if (strtoupper($row->source) === 'MANUAL') {
|
||||
$attrs['source'] = PirepSource::MANUAL;
|
||||
} else {
|
||||
$attrs['source'] = PirepSource::ACARS;
|
||||
@ -550,16 +546,16 @@ class Importer
|
||||
|
||||
# Set the flight type
|
||||
$row->flighttype = strtoupper($row->flighttype);
|
||||
if($row->flighttype === 'P') {
|
||||
if ($row->flighttype === 'P') {
|
||||
$attrs['flight_type'] = FlightType::PASSENGER;
|
||||
} elseif($row->flighttype === 'C') {
|
||||
} elseif ($row->flighttype === 'C') {
|
||||
$attrs['flight_type'] = FlightType::CARGO;
|
||||
} else {
|
||||
$attrs['flight_type'] = FlightType::CHARTER;
|
||||
}
|
||||
|
||||
# Set the flight level of the PIREP is set
|
||||
if(property_exists($row, 'flightlevel')) {
|
||||
if (property_exists($row, 'flightlevel')) {
|
||||
$attrs['level'] = $row->flightlevel;
|
||||
} else {
|
||||
$attrs['level'] = 0;
|
||||
@ -571,11 +567,11 @@ class Importer
|
||||
);
|
||||
|
||||
$source = strtoupper($row->source);
|
||||
if($source === 'SMARTCARS') {
|
||||
if ($source === 'SMARTCARS') {
|
||||
# TODO: Parse smartcars log into the acars table
|
||||
} elseif($source === 'KACARS') {
|
||||
} elseif ($source === 'KACARS') {
|
||||
# TODO: Parse kACARS log into acars table
|
||||
} elseif($source === 'XACARS') {
|
||||
} elseif ($source === 'XACARS') {
|
||||
# TODO: Parse XACARS log into acars table
|
||||
}
|
||||
|
||||
@ -587,7 +583,7 @@ class Importer
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Imported ' . $count . ' pireps');
|
||||
$this->info('Imported '.$count.' pireps');
|
||||
}
|
||||
|
||||
protected function importUsers()
|
||||
@ -596,10 +592,9 @@ class Importer
|
||||
|
||||
$count = 0;
|
||||
foreach ($this->readRows('pilots', 50) as $row) {
|
||||
|
||||
# TODO: What to do about pilot ids
|
||||
|
||||
$name = $row->firstname . ' ' . $row->lastname;
|
||||
$name = $row->firstname.' '.$row->lastname;
|
||||
|
||||
$airline_id = $this->getMapping('airlines', $row->code);
|
||||
$rank_id = $this->getMapping('ranks', $row->rank);
|
||||
@ -608,17 +603,17 @@ class Importer
|
||||
$new_password = Str::random(60);
|
||||
|
||||
$attrs = [
|
||||
'name' => $name,
|
||||
'password' => Hash::make($new_password),
|
||||
'api_key' => Utils::generateApiKey(),
|
||||
'airline_id' => $airline_id,
|
||||
'rank_id' => $rank_id,
|
||||
'name' => $name,
|
||||
'password' => Hash::make($new_password),
|
||||
'api_key' => Utils::generateApiKey(),
|
||||
'airline_id' => $airline_id,
|
||||
'rank_id' => $rank_id,
|
||||
'home_airport_id' => $row->hub,
|
||||
'curr_airport_id' => $row->hub,
|
||||
'flights' => (int)$row->totalflights,
|
||||
'flight_time' => Utils::hoursToMinutes($row->totalhours),
|
||||
'state' => $state,
|
||||
'created_at' => $this->parseDate($row->joindate),
|
||||
'flights' => (int) $row->totalflights,
|
||||
'flight_time' => Utils::hoursToMinutes($row->totalhours),
|
||||
'state' => $state,
|
||||
'created_at' => $this->parseDate($row->joindate),
|
||||
];
|
||||
|
||||
$user = User::updateOrCreate(
|
||||
@ -633,7 +628,7 @@ class Importer
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Imported ' . $count . ' users');
|
||||
$this->info('Imported '.$count.' users');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -641,7 +636,6 @@ class Importer
|
||||
*/
|
||||
protected function findLastPireps()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -665,9 +659,9 @@ class Importer
|
||||
|
||||
// Declare array of classic states
|
||||
$phpvms_classic_states = [
|
||||
'ACTIVE' => 0,
|
||||
'ACTIVE' => 0,
|
||||
'INACTIVE' => 1,
|
||||
'BANNED' => 2,
|
||||
'BANNED' => 2,
|
||||
'ON_LEAVE' => 3
|
||||
];
|
||||
|
||||
@ -682,7 +676,7 @@ class Importer
|
||||
} elseif ($state === $phpvms_classic_states['ON_LEAVE']) {
|
||||
return UserState::ON_LEAVE;
|
||||
} else {
|
||||
$this->error('Unknown status: '. $state);
|
||||
$this->error('Unknown status: '.$state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,18 +4,18 @@ use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\Models\Acars::class, function (Faker $faker) {
|
||||
return [
|
||||
'id' => null,
|
||||
'pirep_id' => null,
|
||||
'log' => $faker->text(100),
|
||||
'lat' => $faker->latitude,
|
||||
'lon' => $faker->longitude,
|
||||
'heading' => $faker->numberBetween(0, 359),
|
||||
'altitude' => $faker->numberBetween(20, 400),
|
||||
'vs' => $faker->numberBetween(-5000, 5000),
|
||||
'gs' => $faker->numberBetween(300, 500),
|
||||
'id' => null,
|
||||
'pirep_id' => null,
|
||||
'log' => $faker->text(100),
|
||||
'lat' => $faker->latitude,
|
||||
'lon' => $faker->longitude,
|
||||
'heading' => $faker->numberBetween(0, 359),
|
||||
'altitude' => $faker->numberBetween(20, 400),
|
||||
'vs' => $faker->numberBetween(-5000, 5000),
|
||||
'gs' => $faker->numberBetween(300, 500),
|
||||
'transponder' => $faker->numberBetween(200, 9999),
|
||||
'autopilot' => $faker->text(10),
|
||||
'fuel_flow' => $faker->randomFloat(2, 100, 1000),
|
||||
'sim_time' => $faker->dateTime('now', 'UTC'),
|
||||
'autopilot' => $faker->text(10),
|
||||
'fuel_flow' => $faker->randomFloat(2, 100, 1000),
|
||||
'sim_time' => $faker->dateTime('now', 'UTC'),
|
||||
];
|
||||
});
|
||||
|
@ -4,21 +4,21 @@ use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\Models\Aircraft::class, function (Faker $faker) {
|
||||
return [
|
||||
'id' => null,
|
||||
'subfleet_id' => function() {
|
||||
'id' => null,
|
||||
'subfleet_id' => function () {
|
||||
return factory(App\Models\Subfleet::class)->create()->id;
|
||||
},
|
||||
'airport_id' => function () {
|
||||
'airport_id' => function () {
|
||||
return factory(App\Models\Airport::class)->create()->id;
|
||||
},
|
||||
'icao' => $faker->unique()->text(5),
|
||||
'name' => $faker->unique()->text(50),
|
||||
'icao' => $faker->unique()->text(5),
|
||||
'name' => $faker->unique()->text(50),
|
||||
'registration' => $faker->unique()->text(10),
|
||||
'hex_code' => \App\Support\ICAO::createHexCode(),
|
||||
'status' => \App\Models\Enums\AircraftStatus::ACTIVE,
|
||||
'state' => \App\Models\Enums\AircraftState::PARKED,
|
||||
'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
|
||||
'updated_at' => function (array $pirep) {
|
||||
'hex_code' => \App\Support\ICAO::createHexCode(),
|
||||
'status' => \App\Models\Enums\AircraftStatus::ACTIVE,
|
||||
'state' => \App\Models\Enums\AircraftState::PARKED,
|
||||
'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
|
||||
'updated_at' => function (array $pirep) {
|
||||
return $pirep['created_at'];
|
||||
},
|
||||
];
|
||||
|
@ -8,15 +8,18 @@ use Hashids\Hashids;
|
||||
*/
|
||||
$factory->define(App\Models\Airline::class, function (Faker $faker) {
|
||||
return [
|
||||
'id' => null,
|
||||
'icao' => function (array $apt) use ($faker) {
|
||||
'id' => null,
|
||||
'icao' => function (array $apt) use ($faker) {
|
||||
$hashids = new Hashids(microtime(), 5);
|
||||
$mt = str_replace('.', '', microtime(true));
|
||||
|
||||
return $hashids->encode($mt);
|
||||
},
|
||||
'iata' => function (array $apt) { return $apt['icao']; },
|
||||
'name' => $faker->sentence(3),
|
||||
'iata' => function (array $apt) {
|
||||
return $apt['icao'];
|
||||
},
|
||||
'name' => $faker->sentence(3),
|
||||
'country' => $faker->country,
|
||||
'active' => 1
|
||||
'active' => 1
|
||||
];
|
||||
});
|
||||
|
@ -6,9 +6,8 @@ use Faker\Generator as Faker;
|
||||
* Add any number of airports. Don't really care if they're real or not
|
||||
*/
|
||||
$factory->define(App\Models\Airport::class, function (Faker $faker) {
|
||||
|
||||
return [
|
||||
'id' => function() {
|
||||
'id' => function () {
|
||||
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
$string = '';
|
||||
$max = strlen($characters) - 1;
|
||||
@ -18,16 +17,20 @@ $factory->define(App\Models\Airport::class, function (Faker $faker) {
|
||||
|
||||
return $string;
|
||||
},
|
||||
'icao' => function(array $apt) { return $apt['id']; },
|
||||
'iata' => function (array $apt) { return $apt['id']; },
|
||||
'name' => $faker->sentence(3),
|
||||
'country' => $faker->country,
|
||||
'timezone' => $faker->timezone,
|
||||
'lat' => $faker->latitude,
|
||||
'lon' => $faker->longitude,
|
||||
'icao' => function (array $apt) {
|
||||
return $apt['id'];
|
||||
},
|
||||
'iata' => function (array $apt) {
|
||||
return $apt['id'];
|
||||
},
|
||||
'name' => $faker->sentence(3),
|
||||
'country' => $faker->country,
|
||||
'timezone' => $faker->timezone,
|
||||
'lat' => $faker->latitude,
|
||||
'lon' => $faker->longitude,
|
||||
'ground_handling_cost' => $faker->randomFloat(2, 0, 500),
|
||||
'fuel_100ll_cost' => $faker->randomFloat(2, 0, 100),
|
||||
'fuel_jeta_cost' => $faker->randomFloat(2, 0, 100),
|
||||
'fuel_mogas_cost' => $faker->randomFloat(2, 0, 100),
|
||||
'fuel_100ll_cost' => $faker->randomFloat(2, 0, 100),
|
||||
'fuel_jeta_cost' => $faker->randomFloat(2, 0, 100),
|
||||
'fuel_mogas_cost' => $faker->randomFloat(2, 0, 100),
|
||||
];
|
||||
});
|
||||
|
@ -4,10 +4,10 @@ use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\Models\Award::class, function (Faker $faker) {
|
||||
return [
|
||||
'id' => null,
|
||||
'name' => $faker->name,
|
||||
'description' => $faker->text(10),
|
||||
'ref_class' => null,
|
||||
'id' => null,
|
||||
'name' => $faker->name,
|
||||
'description' => $faker->text(10),
|
||||
'ref_class' => null,
|
||||
'ref_class_params' => null,
|
||||
];
|
||||
});
|
||||
|
@ -5,14 +5,14 @@ use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\Models\Expense::class, function (Faker $faker) {
|
||||
return [
|
||||
'id' => null,
|
||||
'airline_id' => null,
|
||||
'name' => $faker->text(20),
|
||||
'amount' => $faker->randomFloat(2, 100, 1000),
|
||||
'type' => ExpenseType::FLIGHT,
|
||||
'multiplier' => false,
|
||||
'ref_class' => \App\Models\Expense::class,
|
||||
'id' => null,
|
||||
'airline_id' => null,
|
||||
'name' => $faker->text(20),
|
||||
'amount' => $faker->randomFloat(2, 100, 1000),
|
||||
'type' => ExpenseType::FLIGHT,
|
||||
'multiplier' => false,
|
||||
'ref_class' => \App\Models\Expense::class,
|
||||
'ref_class_id' => null,
|
||||
'active' => true,
|
||||
'active' => true,
|
||||
];
|
||||
});
|
||||
|
@ -4,11 +4,11 @@ use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\Models\Fare::class, function (Faker $faker) {
|
||||
return [
|
||||
'id' => null,
|
||||
'code' => $faker->text(5),
|
||||
'name' => $faker->text(20),
|
||||
'price' => $faker->randomFloat(2, 100, 1000),
|
||||
'cost' => function (array $fare) {
|
||||
'id' => null,
|
||||
'code' => $faker->text(5),
|
||||
'name' => $faker->text(20),
|
||||
'price' => $faker->randomFloat(2, 100, 1000),
|
||||
'cost' => function (array $fare) {
|
||||
return round($fare['price'] / 2);
|
||||
},
|
||||
'capacity' => $faker->randomFloat(0, 20, 500),
|
||||
|
@ -8,14 +8,14 @@ $airlinesAvailable = [1];
|
||||
|
||||
$factory->define(App\Models\Flight::class, function (Faker $faker) use ($airlinesAvailable) {
|
||||
return [
|
||||
'id' => null,
|
||||
'airline_id' => function () {
|
||||
'id' => null,
|
||||
'airline_id' => function () {
|
||||
return factory(App\Models\Airline::class)->create()->id;
|
||||
},
|
||||
'flight_number' => $faker->unique()->numberBetween(10, 1000000),
|
||||
'route_code' => $faker->randomElement(['', $faker->text(5)]),
|
||||
'route_leg' => $faker->randomElement(['', $faker->text(5)]),
|
||||
'dpt_airport_id' => function() {
|
||||
'flight_number' => $faker->unique()->numberBetween(10, 1000000),
|
||||
'route_code' => $faker->randomElement(['', $faker->text(5)]),
|
||||
'route_leg' => $faker->randomElement(['', $faker->text(5)]),
|
||||
'dpt_airport_id' => function () {
|
||||
return factory(App\Models\Airport::class)->create()->id;
|
||||
},
|
||||
'arr_airport_id' => function () {
|
||||
@ -24,15 +24,15 @@ $factory->define(App\Models\Flight::class, function (Faker $faker) use ($airline
|
||||
'alt_airport_id' => function () {
|
||||
return factory(App\Models\Airport::class)->create()->id;
|
||||
},
|
||||
'distance' => $faker->numberBetween(0, 3000),
|
||||
'route' => null,
|
||||
'dpt_time' => $faker->time(),
|
||||
'arr_time' => $faker->time(),
|
||||
'flight_time' => $faker->numberBetween(60, 360),
|
||||
'has_bid' => false,
|
||||
'active' => true,
|
||||
'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
|
||||
'updated_at' => function (array $flight) {
|
||||
'distance' => $faker->numberBetween(0, 3000),
|
||||
'route' => null,
|
||||
'dpt_time' => $faker->time(),
|
||||
'arr_time' => $faker->time(),
|
||||
'flight_time' => $faker->numberBetween(60, 360),
|
||||
'has_bid' => false,
|
||||
'active' => true,
|
||||
'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
|
||||
'updated_at' => function (array $flight) {
|
||||
return $flight['created_at'];
|
||||
},
|
||||
];
|
||||
|
@ -4,6 +4,6 @@ use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\Models\Journal::class, function (Faker $faker) {
|
||||
return [
|
||||
'currency' => 'USD',
|
||||
'currency' => 'USD',
|
||||
];
|
||||
});
|
||||
|
@ -5,13 +5,13 @@ use Faker\Generator as Faker;
|
||||
$factory->define(App\Models\JournalTransactions::class, function (Faker $faker) {
|
||||
return [
|
||||
'transaction_group' => \Ramsey\Uuid\Uuid::uuid4()->toString(),
|
||||
'journal_id' => function () {
|
||||
'journal_id' => function () {
|
||||
return factory(App\Models\Journal::class)->create()->id;
|
||||
},
|
||||
'credit' => $faker->numberBetween(100, 10000),
|
||||
'debit' => $faker->numberBetween(100, 10000),
|
||||
'currency' => 'USD',
|
||||
'memo' => $faker->sentence(6),
|
||||
'post_date' => \Carbon\Carbon::now(),
|
||||
'credit' => $faker->numberBetween(100, 10000),
|
||||
'debit' => $faker->numberBetween(100, 10000),
|
||||
'currency' => 'USD',
|
||||
'memo' => $faker->sentence(6),
|
||||
'post_date' => \Carbon\Carbon::now(),
|
||||
];
|
||||
});
|
||||
|
@ -5,11 +5,11 @@ use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\Models\Navdata::class, function (Faker $faker) {
|
||||
return [
|
||||
'id' => str_replace(' ', '', str_replace('.', '', $faker->unique()->text(5))),
|
||||
'id' => str_replace(' ', '', str_replace('.', '', $faker->unique()->text(5))),
|
||||
'name' => str_replace('.', '', $faker->unique()->word),
|
||||
'type' => $faker->randomElement([NavaidType::VOR, NavaidType::NDB]),
|
||||
'lat' => $faker->latitude,
|
||||
'lon' => $faker->longitude,
|
||||
'lat' => $faker->latitude,
|
||||
'lon' => $faker->longitude,
|
||||
'freq' => $faker->randomFloat(2, 100, 1000),
|
||||
];
|
||||
});
|
||||
|
@ -7,47 +7,46 @@ use Faker\Generator as Faker;
|
||||
* Create a new PIREP
|
||||
*/
|
||||
$factory->define(App\Models\Pirep::class, function (Faker $faker) {
|
||||
|
||||
return [
|
||||
'id' => null,
|
||||
'airline_id' => function () {
|
||||
'id' => null,
|
||||
'airline_id' => function () {
|
||||
return factory(App\Models\Airline::class)->create()->id;
|
||||
},
|
||||
'user_id' => function () {
|
||||
'user_id' => function () {
|
||||
return factory(App\Models\User::class)->create()->id;
|
||||
},
|
||||
'aircraft_id' => function () {
|
||||
'aircraft_id' => function () {
|
||||
return factory(App\Models\Aircraft::class)->create()->id;
|
||||
},
|
||||
'flight_number' => function (array $pirep) {
|
||||
'flight_number' => function (array $pirep) {
|
||||
return factory(App\Models\Flight::class)->create([
|
||||
'airline_id' => $pirep['airline_id']
|
||||
])->flight_number;
|
||||
},
|
||||
'route_code' => null,
|
||||
'route_leg' => null,
|
||||
'dpt_airport_id' => function () {
|
||||
'route_code' => null,
|
||||
'route_leg' => null,
|
||||
'dpt_airport_id' => function () {
|
||||
return factory(App\Models\Airport::class)->create()->id;
|
||||
},
|
||||
'arr_airport_id' => function () {
|
||||
'arr_airport_id' => function () {
|
||||
return factory(App\Models\Airport::class)->create()->id;
|
||||
},
|
||||
'level' => $faker->numberBetween(20, 400),
|
||||
'distance' => $faker->randomFloat(2, 0, 6000),
|
||||
'planned_distance' => $faker->randomFloat(2, 0, 6000),
|
||||
'flight_time' => $faker->numberBetween(60, 360),
|
||||
'level' => $faker->numberBetween(20, 400),
|
||||
'distance' => $faker->randomFloat(2, 0, 6000),
|
||||
'planned_distance' => $faker->randomFloat(2, 0, 6000),
|
||||
'flight_time' => $faker->numberBetween(60, 360),
|
||||
'planned_flight_time' => $faker->numberBetween(60, 360),
|
||||
'zfw' => $faker->randomFloat(2),
|
||||
'block_fuel' => $faker->randomFloat(2, 0, 30000),
|
||||
'fuel_used' => $faker->randomFloat(2, 0, 30000),
|
||||
'route' => $faker->text(200),
|
||||
'notes' => $faker->text(200),
|
||||
'source' => $faker->randomElement([PirepSource::MANUAL, PirepSource::ACARS]),
|
||||
'source_name' => 'Test Factory',
|
||||
'state' => PirepState::PENDING,
|
||||
'status' => PirepStatus::SCHEDULED,
|
||||
'created_at' => Carbon::now()->toDateTimeString(),
|
||||
'updated_at' => function(array $pirep) {
|
||||
'zfw' => $faker->randomFloat(2),
|
||||
'block_fuel' => $faker->randomFloat(2, 0, 30000),
|
||||
'fuel_used' => $faker->randomFloat(2, 0, 30000),
|
||||
'route' => $faker->text(200),
|
||||
'notes' => $faker->text(200),
|
||||
'source' => $faker->randomElement([PirepSource::MANUAL, PirepSource::ACARS]),
|
||||
'source_name' => 'Test Factory',
|
||||
'state' => PirepState::PENDING,
|
||||
'status' => PirepStatus::SCHEDULED,
|
||||
'created_at' => Carbon::now()->toDateTimeString(),
|
||||
'updated_at' => function (array $pirep) {
|
||||
return $pirep['created_at'];
|
||||
},
|
||||
];
|
||||
|
@ -11,13 +11,13 @@ use Faker\Generator as Faker;
|
||||
*/
|
||||
$factory->define(App\Models\Rank::class, function (Faker $faker) {
|
||||
return [
|
||||
'id' => null,
|
||||
'name' => $faker->unique()->text(50),
|
||||
'hours' => $faker->numberBetween(10, 50),
|
||||
'acars_base_pay_rate' => $faker->numberBetween(10, 100),
|
||||
'id' => null,
|
||||
'name' => $faker->unique()->text(50),
|
||||
'hours' => $faker->numberBetween(10, 50),
|
||||
'acars_base_pay_rate' => $faker->numberBetween(10, 100),
|
||||
'manual_base_pay_rate' => $faker->numberBetween(10, 100),
|
||||
'auto_approve_acars' => 0,
|
||||
'auto_approve_manual' => 0,
|
||||
'auto_promote' => 0,
|
||||
'auto_approve_acars' => 0,
|
||||
'auto_approve_manual' => 0,
|
||||
'auto_promote' => 0,
|
||||
];
|
||||
});
|
||||
|
@ -4,12 +4,12 @@ use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\Models\Subfleet::class, function (Faker $faker) {
|
||||
return [
|
||||
'id' => null,
|
||||
'airline_id' => function () {
|
||||
'id' => null,
|
||||
'airline_id' => function () {
|
||||
return factory(App\Models\Airline::class)->create()->id;
|
||||
},
|
||||
'name' => $faker->unique()->text(50),
|
||||
'type' => $faker->unique()->text(7),
|
||||
'name' => $faker->unique()->text(50),
|
||||
'type' => $faker->unique()->text(7),
|
||||
'ground_handling_multiplier' => $faker->numberBetween(50, 200),
|
||||
];
|
||||
});
|
||||
|
@ -3,24 +3,23 @@
|
||||
use App\Models\Enums\UserState;
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\Models\User::class, function (Faker $faker)
|
||||
{
|
||||
$factory->define(App\Models\User::class, function (Faker $faker) {
|
||||
static $password;
|
||||
|
||||
return [
|
||||
'id' => null,
|
||||
'name' => $faker->name,
|
||||
'email' => $faker->safeEmail,
|
||||
'password' => $password ?: $password = Hash::make('secret'),
|
||||
'api_key' => $faker->sha1,
|
||||
'airline_id' => function () {
|
||||
'id' => null,
|
||||
'name' => $faker->name,
|
||||
'email' => $faker->safeEmail,
|
||||
'password' => $password ?: $password = Hash::make('secret'),
|
||||
'api_key' => $faker->sha1,
|
||||
'airline_id' => function () {
|
||||
return factory(App\Models\Airline::class)->create()->id;
|
||||
},
|
||||
'rank_id' => 1,
|
||||
'flights' => $faker->numberBetween(0, 1000),
|
||||
'flight_time' => $faker->numberBetween(0, 10000),
|
||||
'transfer_time' => $faker->numberBetween(0, 10000),
|
||||
'state' => UserState::ACTIVE,
|
||||
'rank_id' => 1,
|
||||
'flights' => $faker->numberBetween(0, 1000),
|
||||
'flight_time' => $faker->numberBetween(0, 10000),
|
||||
'transfer_time' => $faker->numberBetween(0, 10000),
|
||||
'state' => UserState::ACTIVE,
|
||||
'remember_token' => $faker->unique()->text(5),
|
||||
];
|
||||
});
|
||||
|
@ -35,18 +35,18 @@ class CreateSettingsTable extends Migration
|
||||
*/
|
||||
|
||||
$this->addSetting('general.start_date', [
|
||||
'name' => 'Start Date',
|
||||
'group' => 'general',
|
||||
'value' => '',
|
||||
'type' => 'date',
|
||||
'name' => 'Start Date',
|
||||
'group' => 'general',
|
||||
'value' => '',
|
||||
'type' => 'date',
|
||||
'description' => 'The date your VA started',
|
||||
]);
|
||||
|
||||
$this->addSetting('general.admin_email', [
|
||||
'name' => 'Admin Email',
|
||||
'group' => 'general',
|
||||
'value' => '',
|
||||
'type' => 'text',
|
||||
'name' => 'Admin Email',
|
||||
'group' => 'general',
|
||||
'value' => '',
|
||||
'type' => 'text',
|
||||
'description' => 'Email where notices, etc are sent',
|
||||
]);
|
||||
|
||||
@ -60,56 +60,56 @@ class CreateSettingsTable extends Migration
|
||||
]);*/
|
||||
|
||||
$this->addSetting('units.distance', [
|
||||
'name' => 'Distance Units',
|
||||
'group' => 'units',
|
||||
'value' => 'NM',
|
||||
'type' => 'select',
|
||||
'options' => 'km=kilometers,mi=miles,NM=nautical miles',
|
||||
'name' => 'Distance Units',
|
||||
'group' => 'units',
|
||||
'value' => 'NM',
|
||||
'type' => 'select',
|
||||
'options' => 'km=kilometers,mi=miles,NM=nautical miles',
|
||||
'description' => 'The distance unit for display',
|
||||
]);
|
||||
|
||||
$this->addSetting('units.weight', [
|
||||
'name' => 'Weight Units',
|
||||
'group' => 'units',
|
||||
'value' => 'lbs',
|
||||
'type' => 'select',
|
||||
'options' => 'lbs,kg',
|
||||
'name' => 'Weight Units',
|
||||
'group' => 'units',
|
||||
'value' => 'lbs',
|
||||
'type' => 'select',
|
||||
'options' => 'lbs,kg',
|
||||
'description' => 'The weight unit for display',
|
||||
]);
|
||||
|
||||
$this->addSetting('units.speed', [
|
||||
'name' => 'Speed Units',
|
||||
'group' => 'units',
|
||||
'value' => 'knot',
|
||||
'type' => 'select',
|
||||
'options' => 'km/h,knot',
|
||||
'name' => 'Speed Units',
|
||||
'group' => 'units',
|
||||
'value' => 'knot',
|
||||
'type' => 'select',
|
||||
'options' => 'km/h,knot',
|
||||
'description' => 'The speed unit for display',
|
||||
]);
|
||||
|
||||
$this->addSetting('units.altitude', [
|
||||
'name' => 'Altitude Units',
|
||||
'group' => 'units',
|
||||
'value' => 'ft',
|
||||
'type' => 'select',
|
||||
'options' => 'ft=feet,m=meters',
|
||||
'name' => 'Altitude Units',
|
||||
'group' => 'units',
|
||||
'value' => 'ft',
|
||||
'type' => 'select',
|
||||
'options' => 'ft=feet,m=meters',
|
||||
'description' => 'The altitude unit for display',
|
||||
]);
|
||||
|
||||
$this->addSetting('units.fuel', [
|
||||
'name' => 'Fuel Units',
|
||||
'group' => 'units',
|
||||
'value' => 'lbs',
|
||||
'type' => 'select',
|
||||
'options' => 'lbs,kg',
|
||||
'name' => 'Fuel Units',
|
||||
'group' => 'units',
|
||||
'value' => 'lbs',
|
||||
'type' => 'select',
|
||||
'options' => 'lbs,kg',
|
||||
'description' => 'The units for fuel for display',
|
||||
]);
|
||||
|
||||
$this->addSetting('units.volume', [
|
||||
'name' => 'Volume Units',
|
||||
'group' => 'units',
|
||||
'value' => 'gallons',
|
||||
'type' => 'select',
|
||||
'options' => 'gallons,l=liters',
|
||||
'name' => 'Volume Units',
|
||||
'group' => 'units',
|
||||
'value' => 'gallons',
|
||||
'type' => 'select',
|
||||
'options' => 'gallons,l=liters',
|
||||
'description' => 'The units for fuel for display',
|
||||
]);
|
||||
|
||||
@ -118,26 +118,26 @@ class CreateSettingsTable extends Migration
|
||||
*/
|
||||
|
||||
$this->addSetting('bids.disable_flight_on_bid', [
|
||||
'name' => 'Disable flight on bid',
|
||||
'group' => 'bids',
|
||||
'value' => true,
|
||||
'type' => 'boolean',
|
||||
'name' => 'Disable flight on bid',
|
||||
'group' => 'bids',
|
||||
'value' => true,
|
||||
'type' => 'boolean',
|
||||
'description' => 'When a flight is bid on, no one else can bid on it',
|
||||
]);
|
||||
|
||||
$this->addSetting('bids.allow_multiple_bids', [
|
||||
'name' => 'Allow multiple bids',
|
||||
'group' => 'bids',
|
||||
'value' => true,
|
||||
'type' => 'boolean',
|
||||
'name' => 'Allow multiple bids',
|
||||
'group' => 'bids',
|
||||
'value' => true,
|
||||
'type' => 'boolean',
|
||||
'description' => 'Whether or not someone can bid on multiple flights',
|
||||
]);
|
||||
|
||||
$this->addSetting('bids.expire_time', [
|
||||
'name' => 'Expire Time',
|
||||
'group' => 'bids',
|
||||
'value' => 48,
|
||||
'type' => 'int',
|
||||
'name' => 'Expire Time',
|
||||
'group' => 'bids',
|
||||
'value' => 48,
|
||||
'type' => 'int',
|
||||
'description' => 'Number of hours to expire bids after',
|
||||
]);
|
||||
|
||||
@ -146,10 +146,10 @@ class CreateSettingsTable extends Migration
|
||||
*/
|
||||
|
||||
$this->addSetting('pireps.duplicate_check_time', [
|
||||
'name' => 'PIREP duplicate time check',
|
||||
'group' => 'pireps',
|
||||
'value' => 10,
|
||||
'type' => 'int',
|
||||
'name' => 'PIREP duplicate time check',
|
||||
'group' => 'pireps',
|
||||
'value' => 10,
|
||||
'type' => 'int',
|
||||
'description' => 'The time in minutes to check for a duplicate PIREP',
|
||||
]);
|
||||
|
||||
@ -162,26 +162,26 @@ class CreateSettingsTable extends Migration
|
||||
]);*/
|
||||
|
||||
$this->addSetting('pireps.restrict_aircraft_to_rank', [
|
||||
'name' => 'Restrict Aircraft to Ranks',
|
||||
'group' => 'pireps',
|
||||
'value' => true,
|
||||
'type' => 'boolean',
|
||||
'name' => 'Restrict Aircraft to Ranks',
|
||||
'group' => 'pireps',
|
||||
'value' => true,
|
||||
'type' => 'boolean',
|
||||
'description' => 'Aircraft that can be flown are restricted to a user\'s rank',
|
||||
]);
|
||||
|
||||
$this->addSetting('pireps.only_aircraft_at_dep_airport', [
|
||||
'name' => 'Restrict Aircraft At Departure',
|
||||
'group' => 'pireps',
|
||||
'value' => false,
|
||||
'type' => 'boolean',
|
||||
'name' => 'Restrict Aircraft At Departure',
|
||||
'group' => 'pireps',
|
||||
'value' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => 'Only allow aircraft that are at the departure airport',
|
||||
]);
|
||||
|
||||
$this->addSetting('pireps.remove_bid_on_accept', [
|
||||
'name' => 'Remove bid on accept',
|
||||
'group' => 'pireps',
|
||||
'value' => false,
|
||||
'type' => 'boolean',
|
||||
'name' => 'Remove bid on accept',
|
||||
'group' => 'pireps',
|
||||
'value' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => 'When a PIREP is accepted, remove the bid, if it exists',
|
||||
]);
|
||||
|
||||
@ -190,52 +190,52 @@ class CreateSettingsTable extends Migration
|
||||
*/
|
||||
|
||||
$this->addSetting('pilots.id_length', [
|
||||
'name' => 'Pilot ID Length',
|
||||
'group' => 'pilots',
|
||||
'value' => 4,
|
||||
'default' => 4,
|
||||
'type' => 'int',
|
||||
'name' => 'Pilot ID Length',
|
||||
'group' => 'pilots',
|
||||
'value' => 4,
|
||||
'default' => 4,
|
||||
'type' => 'int',
|
||||
'description' => 'The length of a pilot\'s ID',
|
||||
]);
|
||||
|
||||
$this->addSetting('pilots.auto_accept', [
|
||||
'name' => 'Auto Accept New Pilot',
|
||||
'group' => 'pilots',
|
||||
'value' => true,
|
||||
'type' => 'boolean',
|
||||
'name' => 'Auto Accept New Pilot',
|
||||
'group' => 'pilots',
|
||||
'value' => true,
|
||||
'type' => 'boolean',
|
||||
'description' => 'Automatically accept a pilot when they register',
|
||||
]);
|
||||
|
||||
$this->addSetting('pilots.home_hubs_only', [
|
||||
'name' => 'Hubs as home airport',
|
||||
'group' => 'pilots',
|
||||
'value' => false,
|
||||
'type' => 'boolean',
|
||||
'name' => 'Hubs as home airport',
|
||||
'group' => 'pilots',
|
||||
'value' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => 'Pilots can only select hubs as their home airport',
|
||||
]);
|
||||
|
||||
$this->addSetting('pilots.only_flights_from_current', [
|
||||
'name' => 'Flights from Current',
|
||||
'group' => 'pilots',
|
||||
'value' => false,
|
||||
'type' => 'boolean',
|
||||
'name' => 'Flights from Current',
|
||||
'group' => 'pilots',
|
||||
'value' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => 'Only show/allow flights from their current location',
|
||||
]);
|
||||
|
||||
$this->addSetting('pilots.auto_leave_days', [
|
||||
'name' => 'Pilot to ON LEAVE days',
|
||||
'group' => 'pilots',
|
||||
'value' => 30,
|
||||
'default' => 30,
|
||||
'type' => 'int',
|
||||
'name' => 'Pilot to ON LEAVE days',
|
||||
'group' => 'pilots',
|
||||
'value' => 30,
|
||||
'default' => 30,
|
||||
'type' => 'int',
|
||||
'description' => 'Automatically set a pilot to ON LEAVE status after N days of no activity',
|
||||
]);
|
||||
|
||||
$this->addSetting('pilots.hide_inactive', [
|
||||
'name' => 'Hide Inactive Pilots',
|
||||
'group' => 'pilots',
|
||||
'value' => true,
|
||||
'type' => 'boolean',
|
||||
'name' => 'Hide Inactive Pilots',
|
||||
'group' => 'pilots',
|
||||
'value' => true,
|
||||
'type' => 'boolean',
|
||||
'description' => 'Don\'t show inactive pilots in the public view',
|
||||
]);
|
||||
}
|
||||
|
@ -70,18 +70,17 @@ class RolesPermissionsTables extends Migration
|
||||
# create a default user/role
|
||||
$roles = [
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => 'admin',
|
||||
'id' => 1,
|
||||
'name' => 'admin',
|
||||
'display_name' => 'Administrators',
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => 'user',
|
||||
'id' => 2,
|
||||
'name' => 'user',
|
||||
'display_name' => 'Pilot'
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
$this->addData('roles', $roles);
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateAirlinesTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
|
@ -27,7 +27,6 @@ class CreateAircraftsTable extends Migration
|
||||
$table->unique('registration');
|
||||
$table->index('airport_id');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
|
@ -5,7 +5,6 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateFaresTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
|
@ -6,7 +6,6 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateFlightTables extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
|
@ -5,7 +5,6 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateRanksTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
@ -33,10 +32,10 @@ class CreateRanksTable extends Migration
|
||||
*/
|
||||
$ranks = [
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => 'New Pilot',
|
||||
'hours' => 0,
|
||||
'acars_base_pay_rate' => 50,
|
||||
'id' => 1,
|
||||
'name' => 'New Pilot',
|
||||
'hours' => 0,
|
||||
'acars_base_pay_rate' => 50,
|
||||
'manual_base_pay_rate' => 25,
|
||||
]
|
||||
];
|
||||
|
@ -35,7 +35,7 @@ class CreateSubfleetTables extends Migration
|
||||
$table->index(['fare_id', 'subfleet_id']);
|
||||
});
|
||||
|
||||
Schema::create('subfleet_flight', function(Blueprint $table) {
|
||||
Schema::create('subfleet_flight', function (Blueprint $table) {
|
||||
$table->unsignedInteger('subfleet_id');
|
||||
$table->string('flight_id', 12);
|
||||
|
||||
@ -43,7 +43,7 @@ class CreateSubfleetTables extends Migration
|
||||
$table->index(['flight_id', 'subfleet_id']);
|
||||
});
|
||||
|
||||
Schema::create('subfleet_rank', function(Blueprint $table) {
|
||||
Schema::create('subfleet_rank', function (Blueprint $table) {
|
||||
$table->unsignedInteger('rank_id');
|
||||
$table->unsignedInteger('subfleet_id');
|
||||
$table->string('acars_pay')->nullable();
|
||||
|
@ -8,7 +8,6 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreatePirepTables extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
|
@ -22,7 +22,6 @@ class CreateStatsTable extends Migration
|
||||
$table->primary('id');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
/*$this->addCounterGroups([
|
||||
'flights' => 1,
|
||||
]);
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateAwardsTable extends Migration
|
||||
{
|
||||
@ -30,7 +30,6 @@ class CreateAwardsTable extends Migration
|
||||
$table->index(['ref_class']);
|
||||
});
|
||||
|
||||
|
||||
Schema::create('user_awards', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('user_id');
|
||||
|
@ -9,7 +9,6 @@ class CreateExpensesTable extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::create('expenses', function (Blueprint $table) {
|
||||
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('airline_id')->nullable();
|
||||
|
||||
|
@ -9,9 +9,9 @@ class DatabaseSeeder extends Seeder
|
||||
* @var array
|
||||
*/
|
||||
public static $seed_mapper = [
|
||||
'local' => 'dev',
|
||||
'qa' => 'dev',
|
||||
'staging' => 'dev',
|
||||
'local' => 'dev',
|
||||
'qa' => 'dev',
|
||||
'staging' => 'dev',
|
||||
];
|
||||
|
||||
/**
|
||||
@ -20,13 +20,13 @@ class DatabaseSeeder extends Seeder
|
||||
public function run()
|
||||
{
|
||||
$env = App::environment();
|
||||
if(array_key_exists($env, self::$seed_mapper)) {
|
||||
if (array_key_exists($env, self::$seed_mapper)) {
|
||||
$env = self::$seed_mapper[$env];
|
||||
}
|
||||
|
||||
$path = database_path('seeds/'.$env.'.yml');
|
||||
|
||||
if(!file_exists($path)) {
|
||||
if (!file_exists($path)) {
|
||||
$path = database_path('seeds/prod.yml');
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,9 @@ class CronMonthly
|
||||
{
|
||||
use Dispatchable, SerializesModels;
|
||||
|
||||
/**
|
||||
* CronMonthly constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
|
@ -14,6 +14,9 @@ class CronNightly
|
||||
{
|
||||
use Dispatchable, SerializesModels;
|
||||
|
||||
/**
|
||||
* CronNightly constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
|
@ -14,6 +14,9 @@ class CronWeekly
|
||||
{
|
||||
use Dispatchable, SerializesModels;
|
||||
|
||||
/**
|
||||
* CronWeekly constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
|
@ -32,13 +32,12 @@ use Illuminate\Queue\SerializesModels;
|
||||
class Expenses
|
||||
{
|
||||
use Dispatchable, SerializesModels;
|
||||
|
||||
public $pirep;
|
||||
|
||||
/**
|
||||
* @param Pirep|null $pirep
|
||||
*/
|
||||
public function __construct(Pirep $pirep=null)
|
||||
public function __construct(Pirep $pirep = null)
|
||||
{
|
||||
$this->pirep = $pirep;
|
||||
}
|
||||
|
@ -7,12 +7,20 @@ use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class PirepAccepted
|
||||
* @package App\Events
|
||||
*/
|
||||
class PirepAccepted
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public $pirep;
|
||||
|
||||
/**
|
||||
* PirepAccepted constructor.
|
||||
* @param Pirep $pirep
|
||||
*/
|
||||
public function __construct(Pirep $pirep)
|
||||
{
|
||||
$this->pirep = $pirep;
|
||||
|
@ -10,7 +10,6 @@ use Illuminate\Queue\SerializesModels;
|
||||
class PirepFiled
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public $pirep;
|
||||
|
||||
public function __construct(Pirep $pirep)
|
||||
|
@ -7,12 +7,20 @@ use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class PirepRejected
|
||||
* @package App\Events
|
||||
*/
|
||||
class PirepRejected
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public $pirep;
|
||||
|
||||
/**
|
||||
* PirepRejected constructor.
|
||||
* @param Pirep $pirep
|
||||
*/
|
||||
public function __construct(Pirep $pirep)
|
||||
{
|
||||
$this->pirep = $pirep;
|
||||
|
@ -7,6 +7,10 @@ use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class TestEvent
|
||||
* @package App\Events
|
||||
*/
|
||||
class TestEvent
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
@ -15,6 +19,7 @@ class TestEvent
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
* @param User $user
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
|
@ -7,12 +7,20 @@ use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class UserAccepted
|
||||
* @package App\Events
|
||||
*/
|
||||
class UserAccepted
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* UserAccepted constructor.
|
||||
* @param User $user
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
|
@ -7,12 +7,20 @@ use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class UserRegistered
|
||||
* @package App\Events
|
||||
*/
|
||||
class UserRegistered
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* UserRegistered constructor.
|
||||
* @param User $user
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
|
@ -17,6 +17,11 @@ class UserStateChanged
|
||||
|
||||
public $old_state, $user;
|
||||
|
||||
/**
|
||||
* UserStateChanged constructor.
|
||||
* @param User $user
|
||||
* @param $old_state
|
||||
*/
|
||||
public function __construct(User $user, $old_state)
|
||||
{
|
||||
$this->old_state = $old_state;
|
||||
|
@ -7,6 +7,10 @@ use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class UserStatsChanged
|
||||
* @package App\Events
|
||||
*/
|
||||
class UserStatsChanged
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
@ -1,16 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
/**
|
||||
* Class AircraftPermissionDenied
|
||||
* @package App\Exceptions
|
||||
*/
|
||||
class AircraftPermissionDenied extends HttpException
|
||||
{
|
||||
public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = [])
|
||||
{
|
||||
public function __construct(
|
||||
string $message = null,
|
||||
\Exception $previous = null,
|
||||
int $code = 0,
|
||||
array $headers = []
|
||||
) {
|
||||
parent::__construct(
|
||||
400,
|
||||
'User is not allowed to fly this aircraft',
|
||||
|
@ -1,16 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
/**
|
||||
* Class BidExists
|
||||
* @package App\Exceptions
|
||||
*/
|
||||
class BidExists extends HttpException
|
||||
{
|
||||
public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = [])
|
||||
{
|
||||
public function __construct(
|
||||
string $message = null,
|
||||
\Exception $previous = null,
|
||||
int $code = 0,
|
||||
array $headers = []
|
||||
) {
|
||||
parent::__construct(
|
||||
409,
|
||||
'A bid already exists for this flight',
|
||||
|
@ -51,7 +51,7 @@ class Handler extends ExceptionHandler
|
||||
{
|
||||
return [
|
||||
'error' => [
|
||||
'status' => $status_code,
|
||||
'status' => $status_code,
|
||||
'message' => $message,
|
||||
]
|
||||
];
|
||||
@ -60,19 +60,18 @@ class Handler extends ExceptionHandler
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $exception
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $exception
|
||||
* @return mixed
|
||||
*/
|
||||
public function render($request, Exception $exception)
|
||||
{
|
||||
if ($request->is('api/*')) {
|
||||
|
||||
$headers = [];
|
||||
|
||||
Log::error('API Error', $exception->getTrace());
|
||||
|
||||
if($exception instanceof ModelNotFoundException ||
|
||||
if ($exception instanceof ModelNotFoundException ||
|
||||
$exception instanceof NotFoundHttpException) {
|
||||
$error = $this->createError(404, $exception->getMessage());
|
||||
}
|
||||
@ -88,10 +87,10 @@ class Handler extends ExceptionHandler
|
||||
}
|
||||
|
||||
# Create the detailed errors from the validation errors
|
||||
elseif($exception instanceof ValidationException) {
|
||||
elseif ($exception instanceof ValidationException) {
|
||||
$error_messages = [];
|
||||
$errors = $exception->errors();
|
||||
foreach($errors as $field => $error) {
|
||||
foreach ($errors as $field => $error) {
|
||||
$error_messages[] = implode(', ', $error);
|
||||
}
|
||||
|
||||
@ -107,7 +106,7 @@ class Handler extends ExceptionHandler
|
||||
}
|
||||
|
||||
# Only add trace if in dev
|
||||
if(config('app.env') === 'dev') {
|
||||
if (config('app.env') === 'dev') {
|
||||
$error['error']['trace'] = $exception->getTrace()[0];
|
||||
}
|
||||
|
||||
@ -125,14 +124,15 @@ class Handler extends ExceptionHandler
|
||||
/**
|
||||
* Convert an authentication exception into an unauthenticated response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Auth\AuthenticationException $exception
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Auth\AuthenticationException $exception
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
protected function unauthenticated($request, AuthenticationException $exception)
|
||||
{
|
||||
if ($request->expectsJson() || $request->is('api/*')) {
|
||||
$error = $this->createError(401, 'Unauthenticated');
|
||||
|
||||
return response()->json($error, 401);
|
||||
}
|
||||
|
||||
@ -148,13 +148,13 @@ class Handler extends ExceptionHandler
|
||||
{
|
||||
$status = $e->getStatusCode();
|
||||
view()->replaceNamespace('errors', [
|
||||
resource_path('views/layouts/' . config('phpvms.skin') . '/errors'),
|
||||
resource_path('views/layouts/'.config('phpvms.skin').'/errors'),
|
||||
resource_path('views/errors'),
|
||||
__DIR__ . '/views',
|
||||
__DIR__.'/views',
|
||||
]);
|
||||
|
||||
if (view()->exists("errors::{$status}")) {
|
||||
#if (view()->exists('layouts' . config('phpvms.skin') .'.errors.' .$status)) {
|
||||
#if (view()->exists('layouts' . config('phpvms.skin') .'.errors.' .$status)) {
|
||||
return response()->view("errors::{$status}", [
|
||||
'exception' => $e,
|
||||
'SKIN_NAME' => config('phpvms.skin'),
|
||||
|
@ -1,16 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
/**
|
||||
* Class PirepCancelled
|
||||
* @package App\Exceptions
|
||||
*/
|
||||
class PirepCancelled extends HttpException
|
||||
{
|
||||
public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = [])
|
||||
{
|
||||
public function __construct(
|
||||
string $message = null,
|
||||
\Exception $previous = null,
|
||||
int $code = 0,
|
||||
array $headers = []
|
||||
) {
|
||||
parent::__construct(
|
||||
400,
|
||||
'PIREP has been cancelled, updates are not allowed',
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
/**
|
||||
* Class SettingNotFound
|
||||
* @package App\Exceptions
|
||||
*/
|
||||
class SettingNotFound extends HttpException
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -5,8 +5,15 @@ namespace App\Facades;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* Class Utils
|
||||
* @package App\Facades
|
||||
*/
|
||||
class Utils extends Facade
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'utils';
|
||||
@ -19,11 +26,11 @@ class Utils extends Facade
|
||||
*/
|
||||
public static function isObject($obj)
|
||||
{
|
||||
if(!$obj) {
|
||||
if (!$obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if($obj[0] === '{' || $obj[0] === '[') {
|
||||
if ($obj[0] === '{' || $obj[0] === '[') {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -33,15 +40,15 @@ class Utils extends Facade
|
||||
/**
|
||||
* Download a URI. If a file is given, it will save the downloaded
|
||||
* content into that file
|
||||
* @param $uri
|
||||
* @param $uri
|
||||
* @param null $file
|
||||
* @return string
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public static function downloadUrl($uri, $file=null)
|
||||
public static function downloadUrl($uri, $file = null)
|
||||
{
|
||||
$opts = [];
|
||||
if($file !== null) {
|
||||
if ($file !== null) {
|
||||
$opts['sink'] = $file;
|
||||
}
|
||||
|
||||
@ -49,21 +56,20 @@ class Utils extends Facade
|
||||
$response = $client->request('GET', $uri, $opts);
|
||||
|
||||
$body = $response->getBody()->getContents();
|
||||
if($response->getHeader('content-type') === 'application/json') {
|
||||
if ($response->getHeader('content-type') === 'application/json') {
|
||||
$body = \GuzzleHttp\json_decode($body);
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a 40 character API key that a user can use
|
||||
* @return string
|
||||
*/
|
||||
public static function generateApiKey()
|
||||
{
|
||||
$key = substr(sha1(time() . mt_rand()), 0, 20);
|
||||
$key = substr(sha1(time().mt_rand()), 0, 20);
|
||||
return $key;
|
||||
}
|
||||
|
||||
@ -78,7 +84,7 @@ class Utils extends Facade
|
||||
public static function minutesToTimeString($minutes): string
|
||||
{
|
||||
$hm = self::minutesToTimeParts($minutes);
|
||||
return $hm['h']. 'h '. $hm['m'] . 'm';
|
||||
return $hm['h'].'h '.$hm['m'].'m';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,15 +109,15 @@ class Utils extends Facade
|
||||
|
||||
/**
|
||||
* Convert seconds to HH MM format
|
||||
* @param $seconds
|
||||
* @param $seconds
|
||||
* @param bool $incl_sec
|
||||
* @return string
|
||||
*/
|
||||
public static function secondsToTimeString($seconds, $incl_sec=false): string
|
||||
public static function secondsToTimeString($seconds, $incl_sec = false): string
|
||||
{
|
||||
$hms = self::secondsToTimeParts($seconds);
|
||||
$format = $hms['h'].'h '.$hms['m'].'m';
|
||||
if($incl_sec) {
|
||||
if ($incl_sec) {
|
||||
$format .= ' '.$hms['s'].'s';
|
||||
}
|
||||
|
||||
@ -134,7 +140,7 @@ class Utils extends Facade
|
||||
*/
|
||||
public static function secondsToMinutes($seconds)
|
||||
{
|
||||
return ceil($seconds/60);
|
||||
return ceil($seconds / 60);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,18 +150,18 @@ class Utils extends Facade
|
||||
*/
|
||||
public static function minutesToHours($minutes)
|
||||
{
|
||||
return $minutes/60;
|
||||
return $minutes / 60;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $hours
|
||||
* @param $hours
|
||||
* @param null $minutes
|
||||
* @return float|int
|
||||
*/
|
||||
public static function hoursToMinutes($hours, $minutes=null)
|
||||
public static function hoursToMinutes($hours, $minutes = null)
|
||||
{
|
||||
$total = (int) $hours * 60;
|
||||
if($minutes) {
|
||||
if ($minutes) {
|
||||
$total += (int) $minutes;
|
||||
}
|
||||
|
||||
@ -164,12 +170,13 @@ class Utils extends Facade
|
||||
|
||||
/**
|
||||
* 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")
|
||||
* @return int
|
||||
*/
|
||||
public static function setDays(int $datefield, array $day_enums) {
|
||||
foreach($day_enums as $day) {
|
||||
public static function setDays(int $datefield, array $day_enums)
|
||||
{
|
||||
foreach ($day_enums as $day) {
|
||||
$datefield |= $day;
|
||||
}
|
||||
|
||||
@ -179,10 +186,11 @@ class Utils extends Facade
|
||||
/**
|
||||
* Bit check if a day exists within a integer bitfield
|
||||
* @param int $datefield datefield from database
|
||||
* @param int $day_enum Value from config("enum.days")
|
||||
* @param int $day_enum Value from config("enum.days")
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasDay(int $datefield, int $day_enum) {
|
||||
public static function hasDay(int $datefield, int $day_enum)
|
||||
{
|
||||
return ($datefield & $day_enum) === $datefield;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\CreateAircraftRequest;
|
||||
use App\Http\Requests\UpdateAircraftRequest;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Models\Aircraft;
|
||||
use App\Models\Enums\AircraftStatus;
|
||||
use App\Models\Expense;
|
||||
@ -13,8 +14,11 @@ use Flash;
|
||||
use Illuminate\Http\Request;
|
||||
use Prettus\Repository\Criteria\RequestCriteria;
|
||||
|
||||
|
||||
class AircraftController extends BaseController
|
||||
/**
|
||||
* Class AircraftController
|
||||
* @package App\Http\Controllers\Admin
|
||||
*/
|
||||
class AircraftController extends Controller
|
||||
{
|
||||
private $aircraftRepo;
|
||||
|
||||
@ -49,7 +53,7 @@ class AircraftController extends BaseController
|
||||
{
|
||||
return view('admin.aircraft.create', [
|
||||
'subfleets' => Subfleet::all()->pluck('name', 'id'),
|
||||
'statuses' => AircraftStatus::select(true),
|
||||
'statuses' => AircraftStatus::select(true),
|
||||
]);
|
||||
}
|
||||
|
||||
@ -63,6 +67,7 @@ class AircraftController extends BaseController
|
||||
$aircraft = $this->aircraftRepo->create($attrs);
|
||||
|
||||
Flash::success('Aircraft saved successfully.');
|
||||
|
||||
return redirect(route('admin.aircraft.edit', ['id' => $aircraft->id]));
|
||||
}
|
||||
|
||||
@ -75,11 +80,12 @@ class AircraftController extends BaseController
|
||||
|
||||
if (empty($aircraft)) {
|
||||
Flash::error('Aircraft not found');
|
||||
|
||||
return redirect(route('admin.aircraft.index'));
|
||||
}
|
||||
|
||||
return view('admin.aircraft.show', [
|
||||
'aircraft' => $aircraft,
|
||||
'aircraft' => $aircraft,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -92,12 +98,13 @@ class AircraftController extends BaseController
|
||||
|
||||
if (empty($aircraft)) {
|
||||
Flash::error('Aircraft not found');
|
||||
|
||||
return redirect(route('admin.aircraft.index'));
|
||||
}
|
||||
|
||||
return view('admin.aircraft.edit', [
|
||||
'subfleets' => Subfleet::all()->pluck('name', 'id'),
|
||||
'statuses' => AircraftStatus::select(true),
|
||||
'statuses' => AircraftStatus::select(true),
|
||||
'aircraft' => $aircraft,
|
||||
]);
|
||||
}
|
||||
@ -112,6 +119,7 @@ class AircraftController extends BaseController
|
||||
|
||||
if (empty($aircraft)) {
|
||||
Flash::error('Aircraft not found');
|
||||
|
||||
return redirect(route('admin.aircraft.index'));
|
||||
}
|
||||
|
||||
@ -119,6 +127,7 @@ class AircraftController extends BaseController
|
||||
$this->aircraftRepo->update($attrs, $id);
|
||||
|
||||
Flash::success('Aircraft updated successfully.');
|
||||
|
||||
return redirect(route('admin.aircraft.index'));
|
||||
}
|
||||
|
||||
@ -131,12 +140,14 @@ class AircraftController extends BaseController
|
||||
|
||||
if (empty($aircraft)) {
|
||||
Flash::error('Aircraft not found');
|
||||
|
||||
return redirect(route('admin.aircraft.index'));
|
||||
}
|
||||
|
||||
$this->aircraftRepo->delete($id);
|
||||
|
||||
Flash::success('Aircraft deleted successfully.');
|
||||
|
||||
return redirect(route('admin.aircraft.index'));
|
||||
}
|
||||
|
||||
@ -147,6 +158,7 @@ class AircraftController extends BaseController
|
||||
protected function return_expenses_view(?Aircraft $aircraft)
|
||||
{
|
||||
$aircraft->refresh();
|
||||
|
||||
return view('admin.aircraft.expenses', [
|
||||
'aircraft' => $aircraft,
|
||||
]);
|
||||
@ -154,7 +166,7 @@ class AircraftController extends BaseController
|
||||
|
||||
/**
|
||||
* Operations for associating ranks to the subfleet
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws \Exception
|
||||
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\CreateAirlineRequest;
|
||||
use App\Http\Requests\UpdateAirlineRequest;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Repositories\AirlineRepository;
|
||||
use App\Support\Countries;
|
||||
use Flash;
|
||||
@ -11,9 +12,12 @@ use Illuminate\Http\Request;
|
||||
use Prettus\Repository\Criteria\RequestCriteria;
|
||||
use Response;
|
||||
|
||||
class AirlinesController extends BaseController
|
||||
/**
|
||||
* Class AirlinesController
|
||||
* @package App\Http\Controllers\Admin
|
||||
*/
|
||||
class AirlinesController extends Controller
|
||||
{
|
||||
/** @var AirlineRepository */
|
||||
private $airlineRepo;
|
||||
|
||||
/**
|
||||
@ -59,6 +63,7 @@ class AirlinesController extends BaseController
|
||||
$airlines = $this->airlineRepo->create($input);
|
||||
|
||||
Flash::success('Airlines saved successfully.');
|
||||
|
||||
return redirect(route('admin.airlines.index'));
|
||||
}
|
||||
|
||||
@ -73,6 +78,7 @@ class AirlinesController extends BaseController
|
||||
|
||||
if (empty($airlines)) {
|
||||
Flash::error('Airlines not found');
|
||||
|
||||
return redirect(route('admin.airlines.index'));
|
||||
}
|
||||
|
||||
@ -92,18 +98,19 @@ class AirlinesController extends BaseController
|
||||
|
||||
if (empty($airline)) {
|
||||
Flash::error('Airline not found');
|
||||
|
||||
return redirect(route('admin.airlines.index'));
|
||||
}
|
||||
|
||||
return view('admin.airlines.edit', [
|
||||
'airline' => $airline,
|
||||
'airline' => $airline,
|
||||
'countries' => Countries::getSelectList(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified Airlines in storage.
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
* @param UpdateAirlineRequest $request
|
||||
* @return Response
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
@ -114,6 +121,7 @@ class AirlinesController extends BaseController
|
||||
|
||||
if (empty($airlines)) {
|
||||
Flash::error('Airlines not found');
|
||||
|
||||
return redirect(route('admin.airlines.index'));
|
||||
}
|
||||
|
||||
@ -135,12 +143,14 @@ class AirlinesController extends BaseController
|
||||
|
||||
if (empty($airlines)) {
|
||||
Flash::error('Airlines not found');
|
||||
|
||||
return redirect(route('admin.airlines.index'));
|
||||
}
|
||||
|
||||
$this->airlineRepo->delete($id);
|
||||
|
||||
Flash::success('Airlines deleted successfully.');
|
||||
|
||||
return redirect(route('admin.airlines.index'));
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\CreateAirportRequest;
|
||||
use App\Http\Requests\UpdateAirportRequest;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Models\Airport;
|
||||
use App\Models\Expense;
|
||||
use App\Repositories\AirportRepository;
|
||||
@ -13,14 +14,15 @@ use Illuminate\Http\Request;
|
||||
use Jackiedo\Timezonelist\Facades\Timezonelist;
|
||||
use Response;
|
||||
|
||||
|
||||
class AirportController extends BaseController
|
||||
/**
|
||||
* Class AirportController
|
||||
* @package App\Http\Controllers\Admin
|
||||
*/
|
||||
class AirportController extends Controller
|
||||
{
|
||||
/** @var AirportRepository */
|
||||
private $airportRepo;
|
||||
|
||||
/**
|
||||
* AirportController constructor.
|
||||
* @param AirportRepository $airportRepo
|
||||
*/
|
||||
public function __construct(
|
||||
@ -38,14 +40,14 @@ class AirportController extends BaseController
|
||||
public function index(Request $request)
|
||||
{
|
||||
$where = [];
|
||||
if($request->has('icao')) {
|
||||
if ($request->has('icao')) {
|
||||
$where['icao'] = $request->get('icao');
|
||||
}
|
||||
|
||||
$this->airportRepo->pushCriteria(new WhereCriteria($request, $where));
|
||||
$airports = $this->airportRepo
|
||||
->orderBy('icao', 'asc')
|
||||
->paginate();
|
||||
->orderBy('icao', 'asc')
|
||||
->paginate();
|
||||
|
||||
return view('admin.airports.index', [
|
||||
'airports' => $airports,
|
||||
@ -77,6 +79,7 @@ class AirportController extends BaseController
|
||||
$this->airportRepo->create($input);
|
||||
|
||||
Flash::success('Airport saved successfully.');
|
||||
|
||||
return redirect(route('admin.airports.index'));
|
||||
}
|
||||
|
||||
@ -91,6 +94,7 @@ class AirportController extends BaseController
|
||||
|
||||
if (empty($airport)) {
|
||||
Flash::error('Airport not found');
|
||||
|
||||
return redirect(route('admin.airports.index'));
|
||||
}
|
||||
|
||||
@ -110,18 +114,19 @@ class AirportController extends BaseController
|
||||
|
||||
if (empty($airport)) {
|
||||
Flash::error('Airport not found');
|
||||
|
||||
return redirect(route('admin.airports.index'));
|
||||
}
|
||||
|
||||
return view('admin.airports.edit', [
|
||||
'timezones' => Timezonelist::toArray(),
|
||||
'airport' => $airport,
|
||||
'airport' => $airport,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified Airport in storage.
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
* @param UpdateAirportRequest $request
|
||||
* @return Response
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
@ -132,6 +137,7 @@ class AirportController extends BaseController
|
||||
|
||||
if (empty($airport)) {
|
||||
Flash::error('Airport not found');
|
||||
|
||||
return redirect(route('admin.airports.index'));
|
||||
}
|
||||
|
||||
@ -141,6 +147,7 @@ class AirportController extends BaseController
|
||||
$this->airportRepo->update($attrs, $id);
|
||||
|
||||
Flash::success('Airport updated successfully.');
|
||||
|
||||
return redirect(route('admin.airports.index'));
|
||||
}
|
||||
|
||||
@ -155,12 +162,14 @@ class AirportController extends BaseController
|
||||
|
||||
if (empty($airport)) {
|
||||
Flash::error('Airport not found');
|
||||
|
||||
return redirect(route('admin.airports.index'));
|
||||
}
|
||||
|
||||
$this->airportRepo->delete($id);
|
||||
|
||||
Flash::success('Airport deleted successfully.');
|
||||
|
||||
return redirect(route('admin.airports.index'));
|
||||
}
|
||||
|
||||
@ -171,6 +180,7 @@ class AirportController extends BaseController
|
||||
protected function return_expenses_view(?Airport $airport)
|
||||
{
|
||||
$airport->refresh();
|
||||
|
||||
return view('admin.airports.expenses', [
|
||||
'airport' => $airport,
|
||||
]);
|
||||
@ -178,7 +188,7 @@ class AirportController extends BaseController
|
||||
|
||||
/**
|
||||
* Operations for associating ranks to the subfleet
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws \Exception
|
||||
@ -224,6 +234,7 @@ class AirportController extends BaseController
|
||||
$airport = $this->airportRepo->findWithoutFail($id);
|
||||
if (empty($airport)) {
|
||||
Flash::error('Flight not found');
|
||||
|
||||
return redirect(route('admin.flights.index'));
|
||||
}
|
||||
|
||||
|
@ -4,19 +4,25 @@ namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\CreateAwardRequest;
|
||||
use App\Http\Requests\UpdateAwardRequest;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Repositories\AwardRepository;
|
||||
use App\Services\AwardService;
|
||||
use Illuminate\Http\Request;
|
||||
use Flash;
|
||||
use Illuminate\Http\Request;
|
||||
use Prettus\Repository\Criteria\RequestCriteria;
|
||||
use Response;
|
||||
|
||||
class AwardController extends BaseController
|
||||
class AwardController extends Controller
|
||||
{
|
||||
/** @var AwardRepository */
|
||||
private $awardRepository,
|
||||
$awardSvc;
|
||||
$awardSvc;
|
||||
|
||||
/**
|
||||
* AwardController constructor.
|
||||
* @param AwardRepository $awardRepo
|
||||
* @param AwardService $awardSvc
|
||||
*/
|
||||
public function __construct(
|
||||
AwardRepository $awardRepo,
|
||||
AwardService $awardSvc
|
||||
@ -38,13 +44,13 @@ class AwardController extends BaseController
|
||||
$descriptions = [];
|
||||
|
||||
$award_classes = $this->awardSvc->findAllAwardClasses();
|
||||
foreach($award_classes as $class_ref => $award) {
|
||||
foreach ($award_classes as $class_ref => $award) {
|
||||
$awards[$class_ref] = $award->name;
|
||||
$descriptions[$class_ref] = $award->param_description;
|
||||
}
|
||||
|
||||
return [
|
||||
'awards' => $awards,
|
||||
'awards' => $awards,
|
||||
'descriptions' => $descriptions,
|
||||
];
|
||||
}
|
||||
@ -72,8 +78,9 @@ class AwardController extends BaseController
|
||||
public function create()
|
||||
{
|
||||
$class_refs = $this->getAwardClassesAndDescriptions();
|
||||
|
||||
return view('admin.awards.create', [
|
||||
'award_classes' => $class_refs['awards'],
|
||||
'award_classes' => $class_refs['awards'],
|
||||
'award_descriptions' => $class_refs['descriptions'],
|
||||
]);
|
||||
}
|
||||
@ -103,6 +110,7 @@ class AwardController extends BaseController
|
||||
$award = $this->awardRepository->findWithoutFail($id);
|
||||
if (empty($award)) {
|
||||
Flash::error('Award not found');
|
||||
|
||||
return redirect(route('admin.awards.index'));
|
||||
}
|
||||
|
||||
@ -121,20 +129,22 @@ class AwardController extends BaseController
|
||||
$award = $this->awardRepository->findWithoutFail($id);
|
||||
if (empty($award)) {
|
||||
Flash::error('Award not found');
|
||||
|
||||
return redirect(route('admin.awards.index'));
|
||||
}
|
||||
|
||||
$class_refs = $this->getAwardClassesAndDescriptions();
|
||||
|
||||
return view('admin.awards.edit', [
|
||||
'award' => $award,
|
||||
'award_classes' => $class_refs['awards'],
|
||||
'award' => $award,
|
||||
'award_classes' => $class_refs['awards'],
|
||||
'award_descriptions' => $class_refs['descriptions'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified award in storage.
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
* @param UpdateAwardRequest $request
|
||||
* @return Response
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
@ -144,6 +154,7 @@ class AwardController extends BaseController
|
||||
$award = $this->awardRepository->findWithoutFail($id);
|
||||
if (empty($award)) {
|
||||
Flash::error('Award not found');
|
||||
|
||||
return redirect(route('admin.awards.index'));
|
||||
}
|
||||
|
||||
@ -165,6 +176,7 @@ class AwardController extends BaseController
|
||||
$award = $this->awardRepository->findWithoutFail($id);
|
||||
if (empty($award)) {
|
||||
Flash::error('Fare not found');
|
||||
|
||||
return redirect(route('admin.awards.index'));
|
||||
}
|
||||
|
||||
|
@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Response;
|
||||
|
||||
|
||||
class BaseController extends Controller
|
||||
{
|
||||
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Facades\Utils;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Repositories\NewsRepository;
|
||||
use App\Repositories\PirepRepository;
|
||||
use App\Repositories\UserRepository;
|
||||
@ -13,15 +14,21 @@ use Log;
|
||||
use Version;
|
||||
use vierbergenlars\SemVer\version as semver;
|
||||
|
||||
class DashboardController extends BaseController
|
||||
/**
|
||||
* Class DashboardController
|
||||
* @package App\Http\Controllers\Admin
|
||||
*/
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
private $newsRepo, $pirepRepo, $userRepo;
|
||||
private $newsRepo,
|
||||
$pirepRepo,
|
||||
$userRepo;
|
||||
|
||||
/**
|
||||
* DashboardController constructor.
|
||||
* @param NewsRepository $newsRepo
|
||||
* @param NewsRepository $newsRepo
|
||||
* @param PirepRepository $pirepRepo
|
||||
* @param UserRepository $userRepo
|
||||
* @param UserRepository $userRepo
|
||||
*/
|
||||
public function __construct(
|
||||
NewsRepository $newsRepo,
|
||||
@ -46,7 +53,7 @@ class DashboardController extends BaseController
|
||||
$latest_version = new semver(Utils::downloadUrl(config('phpvms.version_file')));
|
||||
|
||||
if (semver::gt($latest_version, $current_version)) {
|
||||
Flash::warning('New version ' . $latest_version . ' is available!');
|
||||
Flash::warning('New version '.$latest_version.' is available!');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
@ -63,9 +70,9 @@ class DashboardController extends BaseController
|
||||
$this->checkNewVersion();
|
||||
|
||||
return view('admin.dashboard.index', [
|
||||
'news' => $this->newsRepo->getLatest(),
|
||||
'news' => $this->newsRepo->getLatest(),
|
||||
'pending_pireps' => $this->pirepRepo->getPendingCount(),
|
||||
'pending_users' => $this->userRepo->getPendingCount(),
|
||||
'pending_users' => $this->userRepo->getPendingCount(),
|
||||
]);
|
||||
}
|
||||
|
||||
@ -76,7 +83,7 @@ class DashboardController extends BaseController
|
||||
*/
|
||||
public function news(Request $request)
|
||||
{
|
||||
if($request->isMethod('post')) {
|
||||
if ($request->isMethod('post')) {
|
||||
$attrs = $request->post();
|
||||
$attrs['user_id'] = Auth::user()->id;
|
||||
|
||||
|
@ -2,8 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\CreateAirlineRequest;
|
||||
use App\Http\Requests\UpdateAirlineRequest;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Models\Enums\ExpenseType;
|
||||
use App\Models\Expense;
|
||||
use App\Repositories\AirlineRepository;
|
||||
@ -13,7 +12,11 @@ use Illuminate\Http\Request;
|
||||
use Prettus\Repository\Criteria\RequestCriteria;
|
||||
use Response;
|
||||
|
||||
class ExpenseController extends BaseController
|
||||
/**
|
||||
* Class ExpenseController
|
||||
* @package App\Http\Controllers\Admin
|
||||
*/
|
||||
class ExpenseController extends Controller
|
||||
{
|
||||
private $airlineRepo,
|
||||
$expenseRepo;
|
||||
@ -73,6 +76,7 @@ class ExpenseController extends BaseController
|
||||
$this->expenseRepo->create($input);
|
||||
|
||||
Flash::success('Expense saved successfully.');
|
||||
|
||||
return redirect(route('admin.expenses.index'));
|
||||
}
|
||||
|
||||
@ -87,6 +91,7 @@ class ExpenseController extends BaseController
|
||||
|
||||
if (empty($expenses)) {
|
||||
Flash::error('expenses not found');
|
||||
|
||||
return redirect(route('admin.expenses.index'));
|
||||
}
|
||||
|
||||
@ -106,11 +111,12 @@ class ExpenseController extends BaseController
|
||||
|
||||
if (empty($expense)) {
|
||||
Flash::error('Expense not found');
|
||||
|
||||
return redirect(route('admin.expenses.index'));
|
||||
}
|
||||
|
||||
return view('admin.expenses.edit', [
|
||||
'expense' => $expense,
|
||||
'expense' => $expense,
|
||||
'airlines_list' => $this->airlineRepo->selectBoxList(true),
|
||||
'expense_types' => ExpenseType::select(),
|
||||
]);
|
||||
@ -118,7 +124,7 @@ class ExpenseController extends BaseController
|
||||
|
||||
/**
|
||||
* Update the specified expenses in storage.
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
@ -129,12 +135,14 @@ class ExpenseController extends BaseController
|
||||
|
||||
if (empty($expenses)) {
|
||||
Flash::error('Expense not found');
|
||||
|
||||
return redirect(route('admin.expenses.index'));
|
||||
}
|
||||
|
||||
$this->expenseRepo->update($request->all(), $id);
|
||||
|
||||
Flash::success('Expense updated successfully.');
|
||||
|
||||
return redirect(route('admin.expenses.index'));
|
||||
}
|
||||
|
||||
@ -149,12 +157,14 @@ class ExpenseController extends BaseController
|
||||
|
||||
if (empty($expenses)) {
|
||||
Flash::error('Expense not found');
|
||||
|
||||
return redirect(route('admin.expenses.index'));
|
||||
}
|
||||
|
||||
$this->expenseRepo->delete($id);
|
||||
|
||||
Flash::success('Expense deleted successfully.');
|
||||
|
||||
return redirect(route('admin.expenses.index'));
|
||||
}
|
||||
}
|
||||
|
@ -4,15 +4,19 @@ namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\CreateFareRequest;
|
||||
use App\Http\Requests\UpdateFareRequest;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Repositories\FareRepository;
|
||||
use Flash;
|
||||
use Illuminate\Http\Request;
|
||||
use Prettus\Repository\Criteria\RequestCriteria;
|
||||
use Response;
|
||||
|
||||
class FareController extends BaseController
|
||||
/**
|
||||
* Class FareController
|
||||
* @package App\Http\Controllers\Admin
|
||||
*/
|
||||
class FareController extends Controller
|
||||
{
|
||||
/** @var FareRepository */
|
||||
private $fareRepository;
|
||||
|
||||
/**
|
||||
@ -75,6 +79,7 @@ class FareController extends BaseController
|
||||
$fare = $this->fareRepository->findWithoutFail($id);
|
||||
if (empty($fare)) {
|
||||
Flash::error('Fare not found');
|
||||
|
||||
return redirect(route('admin.fares.index'));
|
||||
}
|
||||
|
||||
@ -91,6 +96,7 @@ class FareController extends BaseController
|
||||
$fare = $this->fareRepository->findWithoutFail($id);
|
||||
if (empty($fare)) {
|
||||
Flash::error('Fare not found');
|
||||
|
||||
return redirect(route('admin.fares.index'));
|
||||
}
|
||||
|
||||
@ -99,7 +105,7 @@ class FareController extends BaseController
|
||||
|
||||
/**
|
||||
* Update the specified Fare in storage.
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
* @param UpdateFareRequest $request
|
||||
* @return Response
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
@ -109,6 +115,7 @@ class FareController extends BaseController
|
||||
$fare = $this->fareRepository->findWithoutFail($id);
|
||||
if (empty($fare)) {
|
||||
Flash::error('Fare not found');
|
||||
|
||||
return redirect(route('admin.fares.index'));
|
||||
}
|
||||
|
||||
@ -128,6 +135,7 @@ class FareController extends BaseController
|
||||
$fare = $this->fareRepository->findWithoutFail($id);
|
||||
if (empty($fare)) {
|
||||
Flash::error('Fare not found');
|
||||
|
||||
return redirect(route('admin.fares.index'));
|
||||
}
|
||||
|
||||
|
@ -2,12 +2,11 @@
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Interfaces\Controller;
|
||||
use App\Models\Enums\JournalType;
|
||||
use App\Models\Journal;
|
||||
use App\Models\JournalTransaction;
|
||||
use App\Repositories\AirlineRepository;
|
||||
use App\Repositories\JournalRepository;
|
||||
use App\Services\Finance\PirepFinanceService;
|
||||
use App\Support\Dates;
|
||||
use App\Support\Money;
|
||||
use Illuminate\Http\Request;
|
||||
@ -16,25 +15,17 @@ use Illuminate\Http\Request;
|
||||
* Class FinanceController
|
||||
* @package App\Http\Controllers\Admin
|
||||
*/
|
||||
class FinanceController extends BaseController
|
||||
class FinanceController extends Controller
|
||||
{
|
||||
private $airlineRepo,
|
||||
$financeSvc,
|
||||
$journalRepo;
|
||||
private $airlineRepo;
|
||||
|
||||
/**
|
||||
* @param AirlineRepository $airlineRepo
|
||||
* @param PirepFinanceService $financeSvc
|
||||
* @param JournalRepository $journalRepo
|
||||
* @param AirlineRepository $airlineRepo
|
||||
*/
|
||||
public function __construct(
|
||||
AirlineRepository $airlineRepo,
|
||||
PirepFinanceService $financeSvc,
|
||||
JournalRepository $journalRepo
|
||||
AirlineRepository $airlineRepo
|
||||
) {
|
||||
$this->airlineRepo = $airlineRepo;
|
||||
$this->financeSvc = $financeSvc;
|
||||
$this->journalRepo = $journalRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,8 +49,7 @@ class FinanceController extends BaseController
|
||||
$airlines = $this->airlineRepo->orderBy('icao')->all();
|
||||
|
||||
# group by the airline
|
||||
foreach($airlines as $airline) {
|
||||
|
||||
foreach ($airlines as $airline) {
|
||||
# Return all the transactions, grouped by the transaction group
|
||||
$transactions = JournalTransaction::groupBy('transaction_group')
|
||||
->selectRaw('transaction_group, currency,
|
||||
@ -83,16 +73,16 @@ class FinanceController extends BaseController
|
||||
}
|
||||
|
||||
$transaction_groups[] = [
|
||||
'airline' => $airline,
|
||||
'credits' => new Money($sum_all_credits),
|
||||
'debits' => new Money($sum_all_debits),
|
||||
'transactions' => $transactions,
|
||||
'airline' => $airline,
|
||||
'credits' => new Money($sum_all_credits),
|
||||
'debits' => new Money($sum_all_debits),
|
||||
'transactions' => $transactions,
|
||||
];
|
||||
}
|
||||
|
||||
return view('admin.finances.index', [
|
||||
'current_month' => $month,
|
||||
'months_list' => Dates::getMonthsList($first_journal->created_at),
|
||||
'current_month' => $month,
|
||||
'months_list' => Dates::getMonthsList($first_journal->created_at),
|
||||
'transaction_groups' => $transaction_groups,
|
||||
]);
|
||||
}
|
||||
@ -102,6 +92,5 @@ class FinanceController extends BaseController
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\CreateFlightRequest;
|
||||
use App\Http\Requests\UpdateFlightRequest;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Models\Enums\FlightType;
|
||||
use App\Models\Flight;
|
||||
use App\Models\FlightFields;
|
||||
@ -19,7 +20,11 @@ use Flash;
|
||||
use Illuminate\Http\Request;
|
||||
use Response;
|
||||
|
||||
class FlightController extends BaseController
|
||||
/**
|
||||
* Class FlightController
|
||||
* @package App\Http\Controllers\Admin
|
||||
*/
|
||||
class FlightController extends Controller
|
||||
{
|
||||
private $airlineRepo,
|
||||
$airportRepo,
|
||||
@ -31,12 +36,12 @@ class FlightController extends BaseController
|
||||
|
||||
/**
|
||||
* FlightController constructor.
|
||||
* @param AirlineRepository $airlineRepo
|
||||
* @param AirportRepository $airportRepo
|
||||
* @param FareRepository $fareRepo
|
||||
* @param FlightRepository $flightRepo
|
||||
* @param FareService $fareSvc
|
||||
* @param FlightService $flightSvc
|
||||
* @param AirlineRepository $airlineRepo
|
||||
* @param AirportRepository $airportRepo
|
||||
* @param FareRepository $fareRepo
|
||||
* @param FlightRepository $flightRepo
|
||||
* @param FareService $fareSvc
|
||||
* @param FlightService $flightSvc
|
||||
* @param SubfleetRepository $subfleetRepo
|
||||
*/
|
||||
public function __construct(
|
||||
@ -84,8 +89,9 @@ class FlightController extends BaseController
|
||||
public function index(Request $request)
|
||||
{
|
||||
$flights = $this->flightRepo->searchCriteria($request, false)->paginate();
|
||||
|
||||
return view('admin.flights.index', [
|
||||
'flights' => $flights,
|
||||
'flights' => $flights,
|
||||
'airlines' => $this->airlineRepo->selectBoxList(true),
|
||||
'airports' => $this->airportRepo->selectBoxList(true),
|
||||
]);
|
||||
@ -98,9 +104,9 @@ class FlightController extends BaseController
|
||||
public function create()
|
||||
{
|
||||
return view('admin.flights.create', [
|
||||
'flight' => null,
|
||||
'airlines' => $this->airlineRepo->selectBoxList(),
|
||||
'airports' => $this->airportRepo->selectBoxList(true, false),
|
||||
'flight' => null,
|
||||
'airlines' => $this->airlineRepo->selectBoxList(),
|
||||
'airports' => $this->airportRepo->selectBoxList(true, false),
|
||||
'alt_airports' => $this->airportRepo->selectBoxList(true),
|
||||
'flight_types' => FlightType::select(true),
|
||||
]);
|
||||
@ -120,17 +126,18 @@ class FlightController extends BaseController
|
||||
'flight_number' => $input['flight_number'],
|
||||
];
|
||||
|
||||
if(filled($input['route_code'])) {
|
||||
if (filled($input['route_code'])) {
|
||||
$where['route_code'] = $input['route_code'];
|
||||
}
|
||||
|
||||
if(filled($input['route_leg'])) {
|
||||
if (filled($input['route_leg'])) {
|
||||
$where['route_leg'] = $input['route_leg'];
|
||||
}
|
||||
|
||||
$flights = $this->flightRepo->findWhere($where);
|
||||
if($flights->count() > 0) {
|
||||
if ($flights->count() > 0) {
|
||||
Flash::error('Duplicate flight with same number/code/leg found, please change to proceed');
|
||||
|
||||
return redirect()->back()->withInput($request->all());
|
||||
}
|
||||
|
||||
@ -142,6 +149,7 @@ class FlightController extends BaseController
|
||||
$flight = $this->flightRepo->create($input);
|
||||
|
||||
Flash::success('Flight saved successfully.');
|
||||
|
||||
return redirect(route('admin.flights.edit', $flight->id));
|
||||
}
|
||||
|
||||
@ -155,12 +163,14 @@ class FlightController extends BaseController
|
||||
|
||||
if (empty($flight)) {
|
||||
Flash::error('Flight not found');
|
||||
|
||||
return redirect(route('admin.flights.index'));
|
||||
}
|
||||
|
||||
$avail_subfleets = $this->getAvailSubfleets($flight);
|
||||
|
||||
return view('admin.flights.show', [
|
||||
'flight' => $flight,
|
||||
'flight' => $flight,
|
||||
'avail_subfleets' => $avail_subfleets,
|
||||
]);
|
||||
}
|
||||
@ -174,6 +184,7 @@ class FlightController extends BaseController
|
||||
$flight = $this->flightRepo->findWithoutFail($id);
|
||||
if (empty($flight)) {
|
||||
Flash::error('Flight not found');
|
||||
|
||||
return redirect(route('admin.flights.index'));
|
||||
}
|
||||
|
||||
@ -183,18 +194,18 @@ class FlightController extends BaseController
|
||||
$flight->minutes = $time->minutes;
|
||||
|
||||
return view('admin.flights.edit', [
|
||||
'flight' => $flight,
|
||||
'airlines' => $this->airlineRepo->selectBoxList(),
|
||||
'airports' => $this->airportRepo->selectBoxList(),
|
||||
'alt_airports' => $this->airportRepo->selectBoxList(true),
|
||||
'avail_fares' => $this->getAvailFares($flight),
|
||||
'flight' => $flight,
|
||||
'airlines' => $this->airlineRepo->selectBoxList(),
|
||||
'airports' => $this->airportRepo->selectBoxList(),
|
||||
'alt_airports' => $this->airportRepo->selectBoxList(true),
|
||||
'avail_fares' => $this->getAvailFares($flight),
|
||||
'avail_subfleets' => $this->getAvailSubfleets($flight),
|
||||
'flight_types' => FlightType::select(true),
|
||||
'flight_types' => FlightType::select(true),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param UpdateFlightRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
@ -205,6 +216,7 @@ class FlightController extends BaseController
|
||||
|
||||
if (empty($flight)) {
|
||||
Flash::error('Flight not found');
|
||||
|
||||
return redirect(route('admin.flights.index'));
|
||||
}
|
||||
|
||||
@ -227,6 +239,7 @@ class FlightController extends BaseController
|
||||
$flights = $this->flightRepo->findWhere($where);
|
||||
if ($flights->count() > 0) {
|
||||
Flash::error('Duplicate flight with same number/code/leg found, please change to proceed');
|
||||
|
||||
return redirect()->back()->withInput($request->all());
|
||||
}
|
||||
|
||||
@ -239,6 +252,7 @@ class FlightController extends BaseController
|
||||
$this->flightRepo->update($input, $id);
|
||||
|
||||
Flash::success('Flight updated successfully.');
|
||||
|
||||
return redirect(route('admin.flights.index'));
|
||||
}
|
||||
|
||||
@ -253,12 +267,14 @@ class FlightController extends BaseController
|
||||
|
||||
if (empty($flight)) {
|
||||
Flash::error('Flight not found');
|
||||
|
||||
return redirect(route('admin.flights.index'));
|
||||
}
|
||||
|
||||
$this->flightSvc->deleteFlight($flight);
|
||||
|
||||
Flash::success('Flight deleted successfully.');
|
||||
|
||||
return redirect(route('admin.flights.index'));
|
||||
}
|
||||
|
||||
@ -269,6 +285,7 @@ class FlightController extends BaseController
|
||||
protected function return_fields_view($flight)
|
||||
{
|
||||
$flight->refresh();
|
||||
|
||||
return view('admin.flights.flight_fields', [
|
||||
'flight' => $flight,
|
||||
]);
|
||||
@ -285,6 +302,7 @@ class FlightController extends BaseController
|
||||
$flight = $this->flightRepo->findWithoutFail($id);
|
||||
if (empty($flight)) {
|
||||
Flash::error('Flight not found');
|
||||
|
||||
return redirect(route('admin.flights.index'));
|
||||
}
|
||||
|
||||
@ -295,16 +313,12 @@ class FlightController extends BaseController
|
||||
$field->name = $request->name;
|
||||
$field->value = $request->value;
|
||||
$field->save();
|
||||
}
|
||||
|
||||
elseif ($request->isMethod('put')) {
|
||||
} elseif ($request->isMethod('put')) {
|
||||
$field = FlightFields::where('id', $request->field_id)->first();
|
||||
$field->value = $request->value;
|
||||
$field->save();
|
||||
// update the field value
|
||||
}
|
||||
|
||||
// remove custom field from flight
|
||||
} // remove custom field from flight
|
||||
elseif ($request->isMethod('delete')) {
|
||||
FlightFields::destroy($request->field_id);
|
||||
}
|
||||
@ -319,14 +333,15 @@ class FlightController extends BaseController
|
||||
protected function return_subfleet_view($flight)
|
||||
{
|
||||
$avail_subfleets = $this->getAvailSubfleets($flight);
|
||||
|
||||
return view('admin.flights.subfleets', [
|
||||
'flight' => $flight,
|
||||
'flight' => $flight,
|
||||
'avail_subfleets' => $avail_subfleets,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
@ -335,15 +350,14 @@ class FlightController extends BaseController
|
||||
$flight = $this->flightRepo->findWithoutFail($id);
|
||||
if (empty($flight)) {
|
||||
Flash::error('Flight not found');
|
||||
|
||||
return redirect(route('admin.flights.index'));
|
||||
}
|
||||
|
||||
// add aircraft to flight
|
||||
if ($request->isMethod('post')) {
|
||||
$flight->subfleets()->syncWithoutDetaching([$request->subfleet_id]);
|
||||
}
|
||||
|
||||
// remove aircraft from flight
|
||||
} // remove aircraft from flight
|
||||
elseif ($request->isMethod('delete')) {
|
||||
$flight->subfleets()->detach($request->subfleet_id);
|
||||
}
|
||||
@ -360,7 +374,7 @@ class FlightController extends BaseController
|
||||
$all_fares = $this->fareRepo->all();
|
||||
$avail_fares = $all_fares->except($flight->fares->modelKeys());
|
||||
foreach ($avail_fares as $fare) {
|
||||
$retval[$fare->id] = $fare->name .
|
||||
$retval[$fare->id] = $fare->name.
|
||||
' (base price: '.$fare->price.')';
|
||||
}
|
||||
|
||||
@ -374,8 +388,9 @@ class FlightController extends BaseController
|
||||
protected function return_fares_view(Flight $flight)
|
||||
{
|
||||
$flight->refresh();
|
||||
|
||||
return view('admin.flights.fares', [
|
||||
'flight' => $flight,
|
||||
'flight' => $flight,
|
||||
'avail_fares' => $this->getAvailFares($flight),
|
||||
]);
|
||||
}
|
||||
@ -400,6 +415,7 @@ class FlightController extends BaseController
|
||||
if ($request->isMethod('delete')) {
|
||||
$fare = $this->fareRepo->findWithoutFail($request->fare_id);
|
||||
$this->fareSvc->delFareFromFlight($flight, $fare);
|
||||
|
||||
return $this->return_fares_view($flight);
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin;
|
||||
use App\Facades\Utils;
|
||||
use App\Http\Requests\CreatePirepRequest;
|
||||
use App\Http\Requests\UpdatePirepRequest;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Models\Enums\PirepSource;
|
||||
use App\Models\Enums\PirepState;
|
||||
use App\Models\Pirep;
|
||||
@ -27,8 +28,11 @@ use Log;
|
||||
use Prettus\Repository\Criteria\RequestCriteria;
|
||||
use Response;
|
||||
|
||||
|
||||
class PirepController extends BaseController
|
||||
/**
|
||||
* Class PirepController
|
||||
* @package App\Http\Controllers\Admin
|
||||
*/
|
||||
class PirepController extends Controller
|
||||
{
|
||||
private $airportRepo,
|
||||
$airlineRepo,
|
||||
@ -43,16 +47,16 @@ class PirepController extends BaseController
|
||||
|
||||
/**
|
||||
* PirepController constructor.
|
||||
* @param AirportRepository $airportRepo
|
||||
* @param AirlineRepository $airlineRepo
|
||||
* @param AircraftRepository $aircraftRepo
|
||||
* @param FareService $fareSvc
|
||||
* @param JournalRepository $journalRepo
|
||||
* @param PirepRepository $pirepRepo
|
||||
* @param AirportRepository $airportRepo
|
||||
* @param AirlineRepository $airlineRepo
|
||||
* @param AircraftRepository $aircraftRepo
|
||||
* @param FareService $fareSvc
|
||||
* @param JournalRepository $journalRepo
|
||||
* @param PirepRepository $pirepRepo
|
||||
* @param PirepFieldRepository $pirepFieldRepo
|
||||
* @param PirepService $pirepSvc
|
||||
* @param SubfleetRepository $subfleetRepo
|
||||
* @param UserService $userSvc
|
||||
* @param PirepService $pirepSvc
|
||||
* @param SubfleetRepository $subfleetRepo
|
||||
* @param UserService $userSvc
|
||||
*/
|
||||
public function __construct(
|
||||
AirportRepository $airportRepo,
|
||||
@ -83,11 +87,11 @@ class PirepController extends BaseController
|
||||
* @param null $user
|
||||
* @return array
|
||||
*/
|
||||
public function aircraftList($user=null)
|
||||
public function aircraftList($user = null)
|
||||
{
|
||||
$aircraft = [];
|
||||
|
||||
if($user === null) {
|
||||
if ($user === null) {
|
||||
$subfleets = $this->subfleetRepo->all();
|
||||
} else {
|
||||
$subfleets = $this->userSvc->getAllowableSubfleets($user);
|
||||
@ -96,7 +100,7 @@ class PirepController extends BaseController
|
||||
foreach ($subfleets as $subfleet) {
|
||||
$tmp = [];
|
||||
foreach ($subfleet->aircraft as $ac) {
|
||||
$tmp[$ac->id] = $ac['name'] . ' - ' . $ac['registration'];
|
||||
$tmp[$ac->id] = $ac['name'].' - '.$ac['registration'];
|
||||
}
|
||||
|
||||
$aircraft[$subfleet->name] = $tmp;
|
||||
@ -107,7 +111,7 @@ class PirepController extends BaseController
|
||||
|
||||
/**
|
||||
* Save any custom fields found
|
||||
* @param Pirep $pirep
|
||||
* @param Pirep $pirep
|
||||
* @param Request $request
|
||||
*/
|
||||
protected function saveCustomFields(Pirep $pirep, Request $request)
|
||||
@ -120,8 +124,8 @@ class PirepController extends BaseController
|
||||
}
|
||||
|
||||
$custom_fields[] = [
|
||||
'name' => $field->name,
|
||||
'value' => $request->input($field->slug),
|
||||
'name' => $field->name,
|
||||
'value' => $request->input($field->slug),
|
||||
'source' => PirepSource::MANUAL
|
||||
];
|
||||
}
|
||||
@ -132,7 +136,7 @@ class PirepController extends BaseController
|
||||
|
||||
/**
|
||||
* Save the fares that have been specified/saved
|
||||
* @param Pirep $pirep
|
||||
* @param Pirep $pirep
|
||||
* @param Request $request
|
||||
* @throws \Exception
|
||||
*/
|
||||
@ -140,8 +144,7 @@ class PirepController extends BaseController
|
||||
{
|
||||
$fares = [];
|
||||
foreach ($pirep->aircraft->subfleet->fares as $fare) {
|
||||
|
||||
$field_name = 'fare_' . $fare->id;
|
||||
$field_name = 'fare_'.$fare->id;
|
||||
if (!$request->filled($field_name)) {
|
||||
$count = 0;
|
||||
} else {
|
||||
@ -150,7 +153,7 @@ class PirepController extends BaseController
|
||||
|
||||
$fares[] = [
|
||||
'fare_id' => $fare->id,
|
||||
'count' => $count,
|
||||
'count' => $count,
|
||||
];
|
||||
}
|
||||
|
||||
@ -171,7 +174,7 @@ class PirepController extends BaseController
|
||||
Log::info('aircraft', $aircraft->toArray());
|
||||
|
||||
return view('admin.pireps.fares', [
|
||||
'aircraft' => $aircraft,
|
||||
'aircraft' => $aircraft,
|
||||
'read_only' => false,
|
||||
]);
|
||||
}
|
||||
@ -187,8 +190,8 @@ class PirepController extends BaseController
|
||||
$this->pirepRepo->pushCriteria($criterea);
|
||||
|
||||
$pireps = $this->pirepRepo
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate();
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate();
|
||||
|
||||
return view('admin.pireps.index', [
|
||||
'pireps' => $pireps
|
||||
@ -247,6 +250,7 @@ class PirepController extends BaseController
|
||||
$this->saveFares($pirep, $request);
|
||||
|
||||
Flash::success('Pirep saved successfully.');
|
||||
|
||||
return redirect(route('admin.pireps.index'));
|
||||
}
|
||||
|
||||
@ -261,6 +265,7 @@ class PirepController extends BaseController
|
||||
|
||||
if (empty($pirep)) {
|
||||
Flash::error('Pirep not found');
|
||||
|
||||
return redirect(route('admin.pireps.index'));
|
||||
}
|
||||
|
||||
@ -280,6 +285,7 @@ class PirepController extends BaseController
|
||||
$pirep = $this->pirepRepo->findWithoutFail($id);
|
||||
if (empty($pirep)) {
|
||||
Flash::error('Pirep not found');
|
||||
|
||||
return redirect(route('admin.pireps.index'));
|
||||
}
|
||||
|
||||
@ -297,25 +303,25 @@ class PirepController extends BaseController
|
||||
|
||||
# set the fares
|
||||
foreach ($pirep->fares as $fare) {
|
||||
$field_name = 'fare_' . $fare->fare_id;
|
||||
$field_name = 'fare_'.$fare->fare_id;
|
||||
$pirep->{$field_name} = $fare->count;
|
||||
}
|
||||
|
||||
$journal = $this->journalRepo->getAllForObject($pirep, $pirep->airline->journal);
|
||||
|
||||
return view('admin.pireps.edit', [
|
||||
'pirep' => $pirep,
|
||||
'read_only' => $read_only,
|
||||
'aircraft' => $pirep->aircraft,
|
||||
'pirep' => $pirep,
|
||||
'read_only' => $read_only,
|
||||
'aircraft' => $pirep->aircraft,
|
||||
'aircraft_list' => $this->aircraftList(),
|
||||
'airports_list' => $this->airportRepo->selectBoxList(),
|
||||
'airlines_list' => $this->airlineRepo->selectBoxList(),
|
||||
'journal' => $journal,
|
||||
'journal' => $journal,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param UpdatePirepRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
@ -327,6 +333,7 @@ class PirepController extends BaseController
|
||||
|
||||
if (empty($pirep)) {
|
||||
Flash::error('Pirep not found');
|
||||
|
||||
return redirect(route('admin.pireps.index'));
|
||||
}
|
||||
|
||||
@ -343,7 +350,7 @@ class PirepController extends BaseController
|
||||
$pirep = $this->pirepRepo->update($attrs, $id);
|
||||
|
||||
// A route change in the PIREP, so update the saved points in the ACARS table
|
||||
if($pirep->route !== $orig_route) {
|
||||
if ($pirep->route !== $orig_route) {
|
||||
$this->pirepSvc->saveRoute($pirep);
|
||||
}
|
||||
|
||||
@ -351,6 +358,7 @@ class PirepController extends BaseController
|
||||
$this->saveFares($pirep, $request);
|
||||
|
||||
Flash::success('Pirep updated successfully.');
|
||||
|
||||
return redirect(route('admin.pireps.index'));
|
||||
}
|
||||
|
||||
@ -365,12 +373,14 @@ class PirepController extends BaseController
|
||||
|
||||
if (empty($pirep)) {
|
||||
Flash::error('Pirep not found');
|
||||
|
||||
return redirect(route('admin.pireps.index'));
|
||||
}
|
||||
|
||||
$this->pirepRepo->delete($id);
|
||||
|
||||
Flash::success('Pirep deleted successfully.');
|
||||
|
||||
return redirect(route('admin.pireps.index'));
|
||||
}
|
||||
|
||||
@ -384,18 +394,19 @@ class PirepController extends BaseController
|
||||
Log::info('PIREP state update call', [$request->toArray()]);
|
||||
|
||||
$pirep = $this->pirepRepo->findWithoutFail($request->id);
|
||||
if($request->isMethod('post')) {
|
||||
if ($request->isMethod('post')) {
|
||||
$new_status = (int) $request->post('new_status');
|
||||
$pirep = $this->pirepSvc->changeState($pirep, $new_status);
|
||||
}
|
||||
|
||||
$pirep->refresh();
|
||||
|
||||
return view('admin.pireps.actions', ['pirep' => $pirep, 'on_edit_page' => false]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a comment to the Pirep
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
@ -406,16 +417,16 @@ class PirepController extends BaseController
|
||||
$pirep = $this->pirepRepo->findWithoutFail($request->id);
|
||||
if ($request->isMethod('post')) {
|
||||
$comment = new PirepComment([
|
||||
'user_id' => $user->id,
|
||||
'user_id' => $user->id,
|
||||
'pirep_id' => $pirep->id,
|
||||
'comment' => $request->get('comment'),
|
||||
'comment' => $request->get('comment'),
|
||||
]);
|
||||
|
||||
$comment->save();
|
||||
$pirep->refresh();
|
||||
}
|
||||
|
||||
if($request->isMethod('delete')) {
|
||||
if ($request->isMethod('delete')) {
|
||||
$comment = PirepComment::find($request->get('comment_id'));
|
||||
$comment->delete();
|
||||
$pirep->refresh();
|
||||
|
@ -4,15 +4,19 @@ namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\CreatePirepFieldRequest;
|
||||
use App\Http\Requests\UpdatePirepFieldRequest;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Repositories\PirepFieldRepository;
|
||||
use Flash;
|
||||
use Illuminate\Http\Request;
|
||||
use Prettus\Repository\Criteria\RequestCriteria;
|
||||
use Response;
|
||||
|
||||
class PirepFieldController extends BaseController
|
||||
/**
|
||||
* Class PirepFieldController
|
||||
* @package App\Http\Controllers\Admin
|
||||
*/
|
||||
class PirepFieldController extends Controller
|
||||
{
|
||||
/** @var PirepFieldRepository */
|
||||
private $pirepFieldRepo;
|
||||
|
||||
/**
|
||||
@ -21,7 +25,7 @@ class PirepFieldController extends BaseController
|
||||
*/
|
||||
public function __construct(
|
||||
PirepFieldRepository $pirepFieldRepo
|
||||
){
|
||||
) {
|
||||
$this->pirepFieldRepo = $pirepFieldRepo;
|
||||
}
|
||||
|
||||
@ -65,6 +69,7 @@ class PirepFieldController extends BaseController
|
||||
$this->pirepFieldRepo->create($attrs);
|
||||
|
||||
Flash::success('Field added successfully.');
|
||||
|
||||
return redirect(route('admin.pirepfields.index'));
|
||||
}
|
||||
|
||||
@ -79,6 +84,7 @@ class PirepFieldController extends BaseController
|
||||
|
||||
if (empty($field)) {
|
||||
Flash::error('PirepField not found');
|
||||
|
||||
return redirect(route('admin.pirepfields.index'));
|
||||
}
|
||||
|
||||
@ -98,6 +104,7 @@ class PirepFieldController extends BaseController
|
||||
|
||||
if (empty($field)) {
|
||||
Flash::error('Field not found');
|
||||
|
||||
return redirect(route('admin.pirepfields.index'));
|
||||
}
|
||||
|
||||
@ -116,6 +123,7 @@ class PirepFieldController extends BaseController
|
||||
|
||||
if (empty($field)) {
|
||||
Flash::error('PirepField not found');
|
||||
|
||||
return redirect(route('admin.pirepfields.index'));
|
||||
}
|
||||
|
||||
@ -125,6 +133,7 @@ class PirepFieldController extends BaseController
|
||||
$this->pirepFieldRepo->update($attrs, $id);
|
||||
|
||||
Flash::success('Field updated successfully.');
|
||||
|
||||
return redirect(route('admin.pirepfields.index'));
|
||||
}
|
||||
|
||||
@ -139,12 +148,14 @@ class PirepFieldController extends BaseController
|
||||
|
||||
if (empty($field)) {
|
||||
Flash::error('Field not found');
|
||||
|
||||
return redirect(route('admin.pirepfields.index'));
|
||||
}
|
||||
|
||||
$this->pirepFieldRepo->delete($id);
|
||||
|
||||
Flash::success('Field deleted successfully.');
|
||||
|
||||
return redirect(route('admin.pirepfields.index'));
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\CreateRankRequest;
|
||||
use App\Http\Requests\UpdateRankRequest;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Repositories\RankRepository;
|
||||
use App\Repositories\SubfleetRepository;
|
||||
use App\Services\FleetService;
|
||||
@ -13,17 +14,20 @@ use Illuminate\Http\Request;
|
||||
use Prettus\Repository\Criteria\RequestCriteria;
|
||||
use Response;
|
||||
|
||||
class RankController extends BaseController
|
||||
/**
|
||||
* Class RankController
|
||||
* @package App\Http\Controllers\Admin
|
||||
*/
|
||||
class RankController extends Controller
|
||||
{
|
||||
/** @var RankRepository */
|
||||
private $fleetSvc,
|
||||
$rankRepository,
|
||||
$subfleetRepo;
|
||||
|
||||
/**
|
||||
* RankController constructor.
|
||||
* @param FleetService $fleetSvc
|
||||
* @param RankRepository $rankingRepo
|
||||
* @param FleetService $fleetSvc
|
||||
* @param RankRepository $rankingRepo
|
||||
* @param SubfleetRepository $subfleetRepo
|
||||
*/
|
||||
public function __construct(
|
||||
@ -109,6 +113,7 @@ class RankController extends BaseController
|
||||
|
||||
if (empty($rank)) {
|
||||
Flash::error('Ranking not found');
|
||||
|
||||
return redirect(route('admin.ranks.index'));
|
||||
}
|
||||
|
||||
@ -128,19 +133,21 @@ class RankController extends BaseController
|
||||
|
||||
if (empty($rank)) {
|
||||
Flash::error('Ranking not found');
|
||||
|
||||
return redirect(route('admin.ranks.index'));
|
||||
}
|
||||
|
||||
$avail_subfleets = $this->getAvailSubfleets($rank);
|
||||
|
||||
return view('admin.ranks.edit', [
|
||||
'rank' => $rank,
|
||||
'rank' => $rank,
|
||||
'avail_subfleets' => $avail_subfleets,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified Ranking in storage.
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
* @param UpdateRankRequest $request
|
||||
* @return Response
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
@ -151,6 +158,7 @@ class RankController extends BaseController
|
||||
|
||||
if (empty($rank)) {
|
||||
Flash::error('Ranking not found');
|
||||
|
||||
return redirect(route('admin.ranks.index'));
|
||||
}
|
||||
|
||||
@ -158,6 +166,7 @@ class RankController extends BaseController
|
||||
Cache::forget(config('cache.keys.RANKS_PILOT_LIST.key'));
|
||||
|
||||
Flash::success('Ranking updated successfully.');
|
||||
|
||||
return redirect(route('admin.ranks.index'));
|
||||
}
|
||||
|
||||
@ -172,12 +181,14 @@ class RankController extends BaseController
|
||||
|
||||
if (empty($rank)) {
|
||||
Flash::error('Ranking not found');
|
||||
|
||||
return redirect(route('admin.ranks.index'));
|
||||
}
|
||||
|
||||
$this->rankRepository->delete($id);
|
||||
|
||||
Flash::success('Ranking deleted successfully.');
|
||||
|
||||
return redirect(route('admin.ranks.index'));
|
||||
}
|
||||
|
||||
@ -188,15 +199,16 @@ class RankController extends BaseController
|
||||
protected function return_subfleet_view($rank)
|
||||
{
|
||||
$avail_subfleets = $this->getAvailSubfleets($rank);
|
||||
|
||||
return view('admin.ranks.subfleets', [
|
||||
'rank' => $rank,
|
||||
'rank' => $rank,
|
||||
'avail_subfleets' => $avail_subfleets,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subfleet operations on a rank
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
@ -205,6 +217,7 @@ class RankController extends BaseController
|
||||
$rank = $this->rankRepository->findWithoutFail($id);
|
||||
if (empty($rank)) {
|
||||
Flash::error('Rank not found!');
|
||||
|
||||
return redirect(route('admin.ranks.index'));
|
||||
}
|
||||
|
||||
@ -212,17 +225,13 @@ class RankController extends BaseController
|
||||
if ($request->isMethod('post')) {
|
||||
$subfleet = $this->subfleetRepo->find($request->input('subfleet_id'));
|
||||
$this->fleetSvc->addSubfleetToRank($subfleet, $rank);
|
||||
}
|
||||
|
||||
elseif($request->isMethod('put')) {
|
||||
} elseif ($request->isMethod('put')) {
|
||||
$override = [];
|
||||
$override[$request->name] = $request->value;
|
||||
$subfleet = $this->subfleetRepo->find($request->input('subfleet_id'));
|
||||
|
||||
$this->fleetSvc->addSubfleetToRank($subfleet, $rank);
|
||||
}
|
||||
|
||||
// remove aircraft from flight
|
||||
} // remove aircraft from flight
|
||||
elseif ($request->isMethod('delete')) {
|
||||
$subfleet = $this->subfleetRepo->find($request->input('subfleet_id'));
|
||||
$this->fleetSvc->removeSubfleetFromRank($subfleet, $rank);
|
||||
|
@ -2,11 +2,16 @@
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Interfaces\Controller;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
|
||||
class SettingsController extends BaseController
|
||||
/**
|
||||
* Class SettingsController
|
||||
* @package App\Http\Controllers\Admin
|
||||
*/
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the settings. Group them by the setting group
|
||||
@ -16,7 +21,7 @@ class SettingsController extends BaseController
|
||||
$settings = Setting::orderBy('order', 'asc')->get();
|
||||
$settings = $settings->groupBy('group');
|
||||
|
||||
return view('admin.settings.index',[
|
||||
return view('admin.settings.index', [
|
||||
'grouped_settings' => $settings,
|
||||
]);
|
||||
}
|
||||
@ -28,9 +33,9 @@ class SettingsController extends BaseController
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
foreach($request->post() as $id => $value) {
|
||||
foreach ($request->post() as $id => $value) {
|
||||
$setting = Setting::find($id);
|
||||
if(!$setting) {
|
||||
if (!$setting) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -40,6 +45,7 @@ class SettingsController extends BaseController
|
||||
}
|
||||
|
||||
flash('Settings saved!');
|
||||
|
||||
return redirect('/admin/settings');
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\CreateSubfleetRequest;
|
||||
use App\Http\Requests\UpdateSubfleetRequest;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Models\Airline;
|
||||
use App\Models\Enums\FuelType;
|
||||
use App\Models\Expense;
|
||||
@ -19,9 +20,12 @@ use Illuminate\Http\Request;
|
||||
use Prettus\Repository\Criteria\RequestCriteria;
|
||||
use Response;
|
||||
|
||||
class SubfleetController extends BaseController
|
||||
/**
|
||||
* Class SubfleetController
|
||||
* @package App\Http\Controllers\Admin
|
||||
*/
|
||||
class SubfleetController extends Controller
|
||||
{
|
||||
/** @var SubfleetRepository */
|
||||
private $aircraftRepo,
|
||||
$fareRepo,
|
||||
$fareSvc,
|
||||
@ -32,11 +36,11 @@ class SubfleetController extends BaseController
|
||||
/**
|
||||
* SubfleetController constructor.
|
||||
* @param AircraftRepository $aircraftRepo
|
||||
* @param FleetService $fleetSvc
|
||||
* @param RankRepository $rankRepo
|
||||
* @param FleetService $fleetSvc
|
||||
* @param RankRepository $rankRepo
|
||||
* @param SubfleetRepository $subfleetRepo
|
||||
* @param FareRepository $fareRepo
|
||||
* @param FareService $fareSvc
|
||||
* @param FareRepository $fareRepo
|
||||
* @param FareService $fareSvc
|
||||
*/
|
||||
public function __construct(
|
||||
AircraftRepository $aircraftRepo,
|
||||
@ -112,7 +116,7 @@ class SubfleetController extends BaseController
|
||||
public function create()
|
||||
{
|
||||
return view('admin.subfleets.create', [
|
||||
'airlines' => Airline::all()->pluck('name', 'id'),
|
||||
'airlines' => Airline::all()->pluck('name', 'id'),
|
||||
'fuel_types' => FuelType::labels(),
|
||||
]);
|
||||
}
|
||||
@ -129,6 +133,7 @@ class SubfleetController extends BaseController
|
||||
$subfleet = $this->subfleetRepo->create($input);
|
||||
|
||||
Flash::success('Subfleet saved successfully.');
|
||||
|
||||
return redirect(route('admin.subfleets.edit', ['id' => $subfleet->id]));
|
||||
}
|
||||
|
||||
@ -143,12 +148,14 @@ class SubfleetController extends BaseController
|
||||
|
||||
if (empty($subfleet)) {
|
||||
Flash::error('Subfleet not found');
|
||||
|
||||
return redirect(route('admin.subfleets.index'));
|
||||
}
|
||||
|
||||
$avail_fares = $this->getAvailFares($subfleet);
|
||||
|
||||
return view('admin.subfleets.show', [
|
||||
'subfleet' => $subfleet,
|
||||
'subfleet' => $subfleet,
|
||||
'avail_fares' => $avail_fares,
|
||||
]);
|
||||
}
|
||||
@ -164,6 +171,7 @@ class SubfleetController extends BaseController
|
||||
|
||||
if (empty($subfleet)) {
|
||||
Flash::error('Subfleet not found');
|
||||
|
||||
return redirect(route('admin.subfleets.index'));
|
||||
}
|
||||
|
||||
@ -171,17 +179,17 @@ class SubfleetController extends BaseController
|
||||
$avail_ranks = $this->getAvailRanks($subfleet);
|
||||
|
||||
return view('admin.subfleets.edit', [
|
||||
'airlines' => Airline::all()->pluck('name', 'id'),
|
||||
'fuel_types' => FuelType::labels(),
|
||||
'avail_fares' => $avail_fares,
|
||||
'avail_ranks' => $avail_ranks,
|
||||
'subfleet' => $subfleet,
|
||||
'airlines' => Airline::all()->pluck('name', 'id'),
|
||||
'fuel_types' => FuelType::labels(),
|
||||
'avail_fares' => $avail_fares,
|
||||
'avail_ranks' => $avail_ranks,
|
||||
'subfleet' => $subfleet,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified Subfleet in storage.
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
* @param UpdateSubfleetRequest $request
|
||||
* @return Response
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
@ -192,12 +200,14 @@ class SubfleetController extends BaseController
|
||||
|
||||
if (empty($subfleet)) {
|
||||
Flash::error('Subfleet not found');
|
||||
|
||||
return redirect(route('admin.subfleets.index'));
|
||||
}
|
||||
|
||||
$this->subfleetRepo->update($request->all(), $id);
|
||||
|
||||
Flash::success('Subfleet updated successfully.');
|
||||
|
||||
return redirect(route('admin.subfleets.index'));
|
||||
}
|
||||
|
||||
@ -212,20 +222,23 @@ class SubfleetController extends BaseController
|
||||
|
||||
if (empty($subfleet)) {
|
||||
Flash::error('Subfleet not found');
|
||||
|
||||
return redirect(route('admin.subfleets.index'));
|
||||
}
|
||||
|
||||
# Make sure no aircraft are assigned to this subfleet
|
||||
# before trying to delete it, or else things might go boom
|
||||
$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();
|
||||
|
||||
return redirect(route('admin.subfleets.index'));
|
||||
}
|
||||
|
||||
$this->subfleetRepo->delete($id);
|
||||
|
||||
Flash::success('Subfleet deleted successfully.');
|
||||
|
||||
return redirect(route('admin.subfleets.index'));
|
||||
}
|
||||
|
||||
@ -240,7 +253,7 @@ class SubfleetController extends BaseController
|
||||
$avail_ranks = $this->getAvailRanks($subfleet);
|
||||
|
||||
return view('admin.subfleets.ranks', [
|
||||
'subfleet' => $subfleet,
|
||||
'subfleet' => $subfleet,
|
||||
'avail_ranks' => $avail_ranks,
|
||||
]);
|
||||
}
|
||||
@ -263,7 +276,7 @@ class SubfleetController extends BaseController
|
||||
|
||||
/**
|
||||
* Operations for associating ranks to the subfleet
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
@ -284,23 +297,20 @@ class SubfleetController extends BaseController
|
||||
if ($request->isMethod('post')) {
|
||||
$rank = $this->rankRepo->find($request->input('rank_id'));
|
||||
$this->fleetSvc->addSubfleetToRank($subfleet, $rank);
|
||||
}
|
||||
|
||||
elseif ($request->isMethod('put')) {
|
||||
} elseif ($request->isMethod('put')) {
|
||||
$override = [];
|
||||
$rank = $this->rankRepo->find($request->input('rank_id'));
|
||||
$override[$request->name] = $request->value;
|
||||
|
||||
$this->fleetSvc->addSubfleetToRank($subfleet, $rank, $override);
|
||||
}
|
||||
|
||||
// dissassociate fare from teh aircraft
|
||||
} // dissassociate fare from teh aircraft
|
||||
elseif ($request->isMethod('delete')) {
|
||||
$rank = $this->rankRepo->find($request->input('rank_id'));
|
||||
$this->fleetSvc->removeSubfleetFromRank($subfleet, $rank);
|
||||
}
|
||||
|
||||
$subfleet->save();
|
||||
|
||||
return $this->return_ranks_view($subfleet);
|
||||
}
|
||||
|
||||
@ -311,6 +321,7 @@ class SubfleetController extends BaseController
|
||||
protected function return_expenses_view(?Subfleet $subfleet)
|
||||
{
|
||||
$subfleet->refresh();
|
||||
|
||||
return view('admin.subfleets.expenses', [
|
||||
'subfleet' => $subfleet,
|
||||
]);
|
||||
@ -318,7 +329,7 @@ class SubfleetController extends BaseController
|
||||
|
||||
/**
|
||||
* Operations for associating ranks to the subfleet
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws \Exception
|
||||
@ -357,7 +368,7 @@ class SubfleetController extends BaseController
|
||||
|
||||
/**
|
||||
* Operations on fares to the subfleet
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
@ -379,17 +390,13 @@ class SubfleetController extends BaseController
|
||||
if ($request->isMethod('post')) {
|
||||
$fare = $this->fareRepo->find($request->fare_id);
|
||||
$this->fareSvc->setForSubfleet($subfleet, $fare);
|
||||
}
|
||||
|
||||
// update the pivot table with overrides for the fares
|
||||
} // update the pivot table with overrides for the fares
|
||||
elseif ($request->isMethod('put')) {
|
||||
$override = [];
|
||||
$fare = $this->fareRepo->find($request->fare_id);
|
||||
$override[$request->name] = $request->value;
|
||||
$this->fareSvc->setForSubfleet($subfleet, $fare, $override);
|
||||
}
|
||||
|
||||
// dissassociate fare from teh aircraft
|
||||
} // dissassociate fare from teh aircraft
|
||||
elseif ($request->isMethod('delete')) {
|
||||
$fare = $this->fareRepo->find($request->fare_id);
|
||||
$this->fareSvc->delFareFromSubfleet($subfleet, $fare);
|
||||
|
@ -5,7 +5,7 @@ namespace App\Http\Controllers\Admin;
|
||||
use App\Facades\Utils;
|
||||
use App\Http\Requests\CreateUserRequest;
|
||||
use App\Http\Requests\UpdateUserRequest;
|
||||
use App\Models\Airline;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Models\Rank;
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
@ -23,7 +23,11 @@ use Log;
|
||||
use Prettus\Repository\Exceptions\RepositoryException;
|
||||
use Response;
|
||||
|
||||
class UserController extends BaseController
|
||||
/**
|
||||
* Class UserController
|
||||
* @package App\Http\Controllers\Admin
|
||||
*/
|
||||
class UserController extends Controller
|
||||
{
|
||||
private $airlineRepo,
|
||||
$airportRepo,
|
||||
@ -35,9 +39,9 @@ class UserController extends BaseController
|
||||
* UserController constructor.
|
||||
* @param AirlineRepository $airlineRepo
|
||||
* @param AirportRepository $airportRepo
|
||||
* @param PirepRepository $pirepRepo
|
||||
* @param UserRepository $userRepo
|
||||
* @param UserService $userSvc
|
||||
* @param PirepRepository $pirepRepo
|
||||
* @param UserRepository $userRepo
|
||||
* @param UserService $userSvc
|
||||
*/
|
||||
public function __construct(
|
||||
AirlineRepository $airlineRepo,
|
||||
@ -67,7 +71,7 @@ class UserController extends BaseController
|
||||
}
|
||||
|
||||
return view('admin.users.index', [
|
||||
'users' => $users,
|
||||
'users' => $users,
|
||||
'country' => new \League\ISO3166\ISO3166(),
|
||||
]);
|
||||
}
|
||||
@ -82,14 +86,14 @@ class UserController extends BaseController
|
||||
$airports = $this->airportRepo->selectBoxList(false, setting('pilots.home_hubs_only'));
|
||||
|
||||
return view('admin.users.create', [
|
||||
'user' => null,
|
||||
'pireps' => null,
|
||||
'airlines' => $airlines,
|
||||
'user' => null,
|
||||
'pireps' => null,
|
||||
'airlines' => $airlines,
|
||||
'timezones' => Timezonelist::toArray(),
|
||||
'country' => new \League\ISO3166\ISO3166(),
|
||||
'airports' => $airports,
|
||||
'ranks' => Rank::all()->pluck('name', 'id'),
|
||||
'roles' => Role::all()->pluck('name', 'id'),
|
||||
'country' => new \League\ISO3166\ISO3166(),
|
||||
'airports' => $airports,
|
||||
'ranks' => Rank::all()->pluck('name', 'id'),
|
||||
'roles' => Role::all()->pluck('name', 'id'),
|
||||
]);
|
||||
}
|
||||
|
||||
@ -105,6 +109,7 @@ class UserController extends BaseController
|
||||
$user = $this->userRepo->create($input);
|
||||
|
||||
Flash::success('User saved successfully.');
|
||||
|
||||
return redirect(route('admin.users.index'));
|
||||
}
|
||||
|
||||
@ -119,6 +124,7 @@ class UserController extends BaseController
|
||||
|
||||
if (empty($user)) {
|
||||
Flash::error('User not found');
|
||||
|
||||
return redirect(route('admin.users.index'));
|
||||
}
|
||||
|
||||
@ -130,14 +136,14 @@ class UserController extends BaseController
|
||||
$airports = $this->airportRepo->selectBoxList(false, setting('pilots.home_hubs_only'));
|
||||
|
||||
return view('admin.users.show', [
|
||||
'user' => $user,
|
||||
'pireps' => $pireps,
|
||||
'airlines' => $airlines,
|
||||
'user' => $user,
|
||||
'pireps' => $pireps,
|
||||
'airlines' => $airlines,
|
||||
'timezones' => Timezonelist::toArray(),
|
||||
'country' => new \League\ISO3166\ISO3166(),
|
||||
'airports' => $airports,
|
||||
'ranks' => Rank::all()->pluck('name', 'id'),
|
||||
'roles' => Role::all()->pluck('name', 'id'),
|
||||
'country' => new \League\ISO3166\ISO3166(),
|
||||
'airports' => $airports,
|
||||
'ranks' => Rank::all()->pluck('name', 'id'),
|
||||
'roles' => Role::all()->pluck('name', 'id'),
|
||||
]);
|
||||
}
|
||||
|
||||
@ -152,6 +158,7 @@ class UserController extends BaseController
|
||||
|
||||
if (empty($user)) {
|
||||
Flash::error('User not found');
|
||||
|
||||
return redirect(route('admin.users.index'));
|
||||
}
|
||||
|
||||
@ -168,20 +175,20 @@ class UserController extends BaseController
|
||||
$airports = $this->airportRepo->selectBoxList(false, setting('pilots.home_hubs_only'));
|
||||
|
||||
return view('admin.users.edit', [
|
||||
'user' => $user,
|
||||
'pireps' => $pireps,
|
||||
'user' => $user,
|
||||
'pireps' => $pireps,
|
||||
'countries' => $countries,
|
||||
'timezones' => Timezonelist::toArray(),
|
||||
'airports' => $airports,
|
||||
'airlines' => $airlines,
|
||||
'ranks' => Rank::all()->pluck('name', 'id'),
|
||||
'roles' => Role::all()->pluck('name', 'id'),
|
||||
'airports' => $airports,
|
||||
'airlines' => $airlines,
|
||||
'ranks' => Rank::all()->pluck('name', 'id'),
|
||||
'roles' => Role::all()->pluck('name', 'id'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified User in storage.
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
* @param UpdateUserRequest $request
|
||||
* @return Response
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
@ -192,11 +199,12 @@ class UserController extends BaseController
|
||||
|
||||
if (empty($user)) {
|
||||
Flash::error('User not found');
|
||||
|
||||
return redirect(route('admin.users.index'));
|
||||
}
|
||||
|
||||
$req_data = $request->all();
|
||||
if(!$request->filled('password')) {
|
||||
if (!$request->filled('password')) {
|
||||
unset($req_data['password']);
|
||||
} else {
|
||||
$req_data['password'] = Hash::make($req_data['password']);
|
||||
@ -206,17 +214,18 @@ class UserController extends BaseController
|
||||
|
||||
$user = $this->userRepo->update($req_data, $id);
|
||||
|
||||
if($original_user_state !== $user->state) {
|
||||
if ($original_user_state !== $user->state) {
|
||||
$this->userSvc->changeUserState($user, $original_user_state);
|
||||
}
|
||||
|
||||
# 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) {
|
||||
$user->attachRole($value);
|
||||
}
|
||||
|
||||
Flash::success('User updated successfully.');
|
||||
|
||||
return redirect(route('admin.users.index'));
|
||||
}
|
||||
|
||||
@ -231,30 +240,33 @@ class UserController extends BaseController
|
||||
|
||||
if (empty($user)) {
|
||||
Flash::error('User not found');
|
||||
|
||||
return redirect(route('admin.users.index'));
|
||||
}
|
||||
|
||||
$this->userRepo->delete($id);
|
||||
|
||||
Flash::success('User deleted successfully.');
|
||||
|
||||
return redirect(route('admin.users.index'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Regenerate the user's API key
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*/
|
||||
public function regen_apikey($id, Request $request)
|
||||
{
|
||||
$user = User::find($id);
|
||||
Log::info('Regenerating API key "' . $user->pilot_id . '"');
|
||||
Log::info('Regenerating API key "'.$user->pilot_id.'"');
|
||||
|
||||
$user->api_key = Utils::generateApiKey();
|
||||
$user->save();
|
||||
|
||||
flash('New API key generated!')->success();
|
||||
|
||||
return redirect(route('admin.users.edit', ['id' => $id]));
|
||||
}
|
||||
}
|
||||
|
@ -2,30 +2,31 @@
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Interfaces\Controller;
|
||||
use App\Repositories\AcarsRepository;
|
||||
use App\Repositories\PirepRepository;
|
||||
use App\Services\GeoService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
class AcarsController extends RestController
|
||||
/**
|
||||
* Class AcarsController
|
||||
* @package App\Http\Controllers\Api
|
||||
*/
|
||||
class AcarsController extends Controller
|
||||
{
|
||||
protected $acarsRepo, $geoSvc, $pirepRepo;
|
||||
private $acarsRepo,
|
||||
$geoSvc;
|
||||
|
||||
/**
|
||||
* AcarsController constructor.
|
||||
* @param GeoService $geoSvc
|
||||
* @param GeoService $geoSvc
|
||||
* @param AcarsRepository $acarsRepo
|
||||
* @param PirepRepository $pirepRepo
|
||||
*/
|
||||
public function __construct(
|
||||
GeoService $geoSvc,
|
||||
AcarsRepository $acarsRepo,
|
||||
PirepRepository $pirepRepo
|
||||
AcarsRepository $acarsRepo
|
||||
) {
|
||||
$this->geoSvc = $geoSvc;
|
||||
$this->acarsRepo = $acarsRepo;
|
||||
$this->pirepRepo = $pirepRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,12 +3,17 @@
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Resources\Airline as AirlineResource;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Repositories\AirlineRepository;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AirlineController extends RestController
|
||||
/**
|
||||
* Class AirlineController
|
||||
* @package App\Http\Controllers\Api
|
||||
*/
|
||||
class AirlineController extends Controller
|
||||
{
|
||||
protected $airlineRepo;
|
||||
private $airlineRepo;
|
||||
|
||||
/**
|
||||
* AirlineController constructor.
|
||||
@ -43,6 +48,7 @@ class AirlineController extends RestController
|
||||
public function get($id)
|
||||
{
|
||||
$id = strtoupper($id);
|
||||
|
||||
return new AirlineResource($this->airlineRepo->find($id));
|
||||
}
|
||||
}
|
||||
|
@ -3,15 +3,20 @@
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Resources\Airport as AirportResource;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Repositories\AirportRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Log;
|
||||
use VaCentral\Airport as AirportLookup;
|
||||
|
||||
class AirportController extends RestController
|
||||
/**
|
||||
* Class AirportController
|
||||
* @package App\Http\Controllers\Api
|
||||
*/
|
||||
class AirportController extends Controller
|
||||
{
|
||||
protected $airportRepo;
|
||||
private $airportRepo;
|
||||
|
||||
/**
|
||||
* AirportController constructor.
|
||||
@ -66,6 +71,7 @@ class AirportController extends RestController
|
||||
public function get($id)
|
||||
{
|
||||
$id = strtoupper($id);
|
||||
|
||||
return new AirportResource($this->airportRepo->find($id));
|
||||
}
|
||||
|
||||
@ -77,13 +83,14 @@ class AirportController extends RestController
|
||||
public function lookup($id)
|
||||
{
|
||||
$airport = Cache::remember(
|
||||
config('cache.keys.AIRPORT_VACENTRAL_LOOKUP.key') . $id,
|
||||
config('cache.keys.AIRPORT_VACENTRAL_LOOKUP.key').$id,
|
||||
config('cache.keys.RANKS_PILOT_LIST.time'),
|
||||
function () use ($id) {
|
||||
try {
|
||||
return AirportLookup::get($id);
|
||||
} catch (\VaCentral\HttpException $e) {
|
||||
Log::error($e);
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,19 @@ namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Resources\Aircraft as AircraftResource;
|
||||
use App\Http\Resources\Subfleet as SubfleetResource;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Repositories\AircraftRepository;
|
||||
use App\Repositories\SubfleetRepository;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FleetController extends RestController
|
||||
/**
|
||||
* Class FleetController
|
||||
* @package App\Http\Controllers\Api
|
||||
*/
|
||||
class FleetController extends Controller
|
||||
{
|
||||
protected $aircraftRepo, $subfleetRepo;
|
||||
private $aircraftRepo,
|
||||
$subfleetRepo;
|
||||
|
||||
/**
|
||||
* FleetController constructor.
|
||||
@ -32,8 +38,8 @@ class FleetController extends RestController
|
||||
public function index()
|
||||
{
|
||||
$subfleets = $this->subfleetRepo
|
||||
->with(['aircraft', 'airline', 'fares', 'ranks'])
|
||||
->paginate();
|
||||
->with(['aircraft', 'airline', 'fares', 'ranks'])
|
||||
->paginate();
|
||||
|
||||
return SubfleetResource::collection($subfleets);
|
||||
}
|
||||
@ -41,23 +47,23 @@ class FleetController extends RestController
|
||||
/**
|
||||
* Get a specific aircraft. Query string required to specify the tail
|
||||
* /api/aircraft/XYZ?type=registration
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return AircraftResource
|
||||
*/
|
||||
public function get_aircraft($id, Request $request)
|
||||
{
|
||||
$where = [];
|
||||
if($request->filled('type')) {
|
||||
if ($request->filled('type')) {
|
||||
$where[$request->get('type')] = $id;
|
||||
} else {
|
||||
$where['id'] = $id;
|
||||
}
|
||||
|
||||
$aircraft = $this->aircraftRepo
|
||||
->with(['subfleet', 'subfleet.fares'])
|
||||
->findWhere($where)
|
||||
->first();
|
||||
->with(['subfleet', 'subfleet.fares'])
|
||||
->findWhere($where)
|
||||
->first();
|
||||
|
||||
return new AircraftResource($aircraft);
|
||||
}
|
||||
|
@ -4,10 +4,10 @@ namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Resources\Flight as FlightResource;
|
||||
use App\Http\Resources\Navdata as NavdataResource;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Repositories\Criteria\WhereCriteria;
|
||||
use App\Repositories\FlightRepository;
|
||||
use App\Services\FlightService;
|
||||
use App\Services\UserService;
|
||||
use Auth;
|
||||
use Illuminate\Http\Request;
|
||||
use Prettus\Repository\Criteria\RequestCriteria;
|
||||
@ -17,24 +17,22 @@ use Prettus\Repository\Exceptions\RepositoryException;
|
||||
* Class FlightController
|
||||
* @package App\Http\Controllers\Api
|
||||
*/
|
||||
class FlightController extends RestController
|
||||
class FlightController extends Controller
|
||||
{
|
||||
protected $flightRepo, $flightSvc, $userSvc;
|
||||
private $flightRepo,
|
||||
$flightSvc;
|
||||
|
||||
/**
|
||||
* FlightController constructor.
|
||||
* @param FlightRepository $flightRepo
|
||||
* @param FlightService $flightSvc
|
||||
* @param UserService $userSvc
|
||||
* @param FlightService $flightSvc
|
||||
*/
|
||||
public function __construct(
|
||||
FlightRepository $flightRepo,
|
||||
FlightService $flightSvc,
|
||||
UserService $userSvc
|
||||
FlightService $flightSvc
|
||||
) {
|
||||
$this->flightRepo = $flightRepo;
|
||||
$this->flightSvc = $flightSvc;
|
||||
$this->userSvc = $userSvc;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,10 +50,10 @@ class FlightController extends RestController
|
||||
}
|
||||
|
||||
$flights = $this->flightRepo
|
||||
->whereOrder($where, 'flight_number', 'asc')
|
||||
->paginate();
|
||||
->whereOrder($where, 'flight_number', 'asc')
|
||||
->paginate();
|
||||
|
||||
foreach($flights as $flight) {
|
||||
foreach ($flights as $flight) {
|
||||
$this->flightSvc->filterSubfleets($user, $flight);
|
||||
}
|
||||
|
||||
@ -105,7 +103,7 @@ class FlightController extends RestController
|
||||
|
||||
/**
|
||||
* Get a flight's route
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
||||
*/
|
||||
|
@ -16,6 +16,7 @@ use App\Http\Resources\AcarsRoute as AcarsRouteResource;
|
||||
use App\Http\Resources\JournalTransaction as JournalTransactionResource;
|
||||
use App\Http\Resources\Pirep as PirepResource;
|
||||
use App\Http\Resources\PirepComment as PirepCommentResource;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Models\Acars;
|
||||
use App\Models\Enums\AcarsType;
|
||||
use App\Models\Enums\PirepSource;
|
||||
@ -35,7 +36,11 @@ use Auth;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
|
||||
class PirepController extends RestController
|
||||
/**
|
||||
* Class PirepController
|
||||
* @package App\Http\Controllers\Api
|
||||
*/
|
||||
class PirepController extends Controller
|
||||
{
|
||||
private $acarsRepo,
|
||||
$fareSvc,
|
||||
@ -48,13 +53,14 @@ class PirepController extends RestController
|
||||
|
||||
/**
|
||||
* PirepController constructor.
|
||||
* @param AcarsRepository $acarsRepo
|
||||
* @param AcarsRepository $acarsRepo
|
||||
* @param FareService $fareSvc
|
||||
* @param PirepFinanceService $financeSvc
|
||||
* @param GeoService $geoSvc
|
||||
* @param JournalRepository $journalRepo
|
||||
* @param PirepRepository $pirepRepo
|
||||
* @param PirepService $pirepSvc
|
||||
* @param UserService $userSvc
|
||||
* @param GeoService $geoSvc
|
||||
* @param JournalRepository $journalRepo
|
||||
* @param PirepRepository $pirepRepo
|
||||
* @param PirepService $pirepSvc
|
||||
* @param UserService $userSvc
|
||||
*/
|
||||
public function __construct(
|
||||
AcarsRepository $acarsRepo,
|
||||
@ -98,7 +104,7 @@ class PirepController extends RestController
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pirep
|
||||
* @param $pirep
|
||||
* @param Request $request
|
||||
*/
|
||||
protected function updateFields($pirep, Request $request)
|
||||
@ -110,8 +116,8 @@ class PirepController extends RestController
|
||||
$pirep_fields = [];
|
||||
foreach ($request->input('fields') as $field_name => $field_value) {
|
||||
$pirep_fields[] = [
|
||||
'name' => $field_name,
|
||||
'value' => $field_value,
|
||||
'name' => $field_name,
|
||||
'value' => $field_value,
|
||||
'source' => $pirep->source,
|
||||
];
|
||||
}
|
||||
@ -121,21 +127,21 @@ class PirepController extends RestController
|
||||
|
||||
/**
|
||||
* Save the fares
|
||||
* @param $pirep
|
||||
* @param $pirep
|
||||
* @param Request $request
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function updateFares($pirep, Request $request)
|
||||
{
|
||||
if(!$request->filled('fares')) {
|
||||
if (!$request->filled('fares')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$fares = [];
|
||||
foreach($request->post('fares') as $fare) {
|
||||
foreach ($request->post('fares') as $fare) {
|
||||
$fares[] = [
|
||||
'fare_id' => $fare['id'],
|
||||
'count' => $fare['count'],
|
||||
'count' => $fare['count'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -168,7 +174,7 @@ class PirepController extends RestController
|
||||
$pirep = new Pirep($attrs);
|
||||
|
||||
# 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)) {
|
||||
$can_use_ac = $this->userSvc->aircraftAllowed($user, $pirep->aircraft_id);
|
||||
if (!$can_use_ac) {
|
||||
throw new AircraftPermissionDenied();
|
||||
@ -177,7 +183,7 @@ class PirepController extends RestController
|
||||
|
||||
# Find if there's a duplicate, if so, let's work on that
|
||||
$dupe_pirep = $this->pirepSvc->findDuplicate($pirep);
|
||||
if($dupe_pirep !== false) {
|
||||
if ($dupe_pirep !== false) {
|
||||
$pirep = $dupe_pirep;
|
||||
$this->checkCancelled($pirep);
|
||||
}
|
||||
@ -198,7 +204,7 @@ class PirepController extends RestController
|
||||
* Once ACARS updates are being processed, then it can go into an 'ENROUTE'
|
||||
* status, and whatever other statuses may be defined
|
||||
*
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param UpdateRequest $request
|
||||
* @return PirepResource
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
@ -208,7 +214,7 @@ class PirepController extends RestController
|
||||
*/
|
||||
public function update($id, UpdateRequest $request)
|
||||
{
|
||||
Log::info('PIREP Update, user ' . Auth::id(), $request->post());
|
||||
Log::info('PIREP Update, user '.Auth::id(), $request->post());
|
||||
|
||||
$user = Auth::user();
|
||||
$pirep = $this->pirepRepo->find($id);
|
||||
@ -236,7 +242,7 @@ class PirepController extends RestController
|
||||
|
||||
/**
|
||||
* File the PIREP
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param FileRequest $request
|
||||
* @return PirepResource
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
@ -246,7 +252,7 @@ class PirepController extends RestController
|
||||
*/
|
||||
public function file($id, FileRequest $request)
|
||||
{
|
||||
Log::info('PIREP file, user ' . Auth::id(), $request->post());
|
||||
Log::info('PIREP file, user '.Auth::id(), $request->post());
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
@ -283,7 +289,7 @@ class PirepController extends RestController
|
||||
# route that's been posted from the PIREP
|
||||
$w = ['pirep_id' => $pirep->id, 'type' => AcarsType::ROUTE];
|
||||
$count = Acars::where($w)->count(['id']);
|
||||
if($count === 0) {
|
||||
if ($count === 0) {
|
||||
$this->pirepSvc->saveRoute($pirep);
|
||||
}
|
||||
|
||||
@ -292,14 +298,14 @@ class PirepController extends RestController
|
||||
|
||||
/**
|
||||
* Cancel the PIREP
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return PirepResource
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
*/
|
||||
public function cancel($id, Request $request)
|
||||
{
|
||||
Log::info('PIREP Cancel, user ' . Auth::id(), $request->post());
|
||||
Log::info('PIREP Cancel, user '.Auth::id(), $request->post());
|
||||
|
||||
$pirep = $this->pirepRepo->update([
|
||||
'state' => PirepState::CANCELLED,
|
||||
@ -310,7 +316,7 @@ class PirepController extends RestController
|
||||
|
||||
/**
|
||||
* Return the GeoJSON for the ACARS line
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory
|
||||
*/
|
||||
@ -326,7 +332,7 @@ class PirepController extends RestController
|
||||
|
||||
/**
|
||||
* Return the routes for the ACARS line
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return AcarsRouteResource
|
||||
*/
|
||||
@ -336,13 +342,13 @@ class PirepController extends RestController
|
||||
|
||||
return new AcarsRouteResource(Acars::where([
|
||||
'pirep_id' => $id,
|
||||
'type' => AcarsType::FLIGHT_PATH
|
||||
'type' => AcarsType::FLIGHT_PATH
|
||||
])->orderBy('created_at', 'asc')->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Post ACARS updates for a PIREP
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param PositionRequest $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
@ -361,8 +367,7 @@ class PirepController extends RestController
|
||||
|
||||
$count = 0;
|
||||
$positions = $request->post('positions');
|
||||
foreach($positions as $position)
|
||||
{
|
||||
foreach ($positions as $position) {
|
||||
$position['pirep_id'] = $id;
|
||||
$position['type'] = AcarsType::FLIGHT_PATH;
|
||||
|
||||
@ -376,13 +381,13 @@ class PirepController extends RestController
|
||||
$pirep->status = PirepStatus::ENROUTE;
|
||||
$pirep->save();
|
||||
|
||||
return $this->message($count . ' positions added', $count);
|
||||
return $this->message($count.' positions added', $count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Post ACARS LOG update for a PIREP. These updates won't show up on the map
|
||||
* But rather in a log file.
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param LogRequest $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
@ -398,8 +403,7 @@ class PirepController extends RestController
|
||||
|
||||
$count = 0;
|
||||
$logs = $request->post('logs');
|
||||
foreach($logs as $log) {
|
||||
|
||||
foreach ($logs as $log) {
|
||||
$log['pirep_id'] = $id;
|
||||
$log['type'] = AcarsType::LOG;
|
||||
|
||||
@ -408,13 +412,13 @@ class PirepController extends RestController
|
||||
++$count;
|
||||
}
|
||||
|
||||
return $this->message($count . ' logs added', $count);
|
||||
return $this->message($count.' logs added', $count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Post ACARS LOG update for a PIREP. These updates won't show up on the map
|
||||
* But rather in a log file.
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param EventRequest $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
@ -426,12 +430,11 @@ class PirepController extends RestController
|
||||
$pirep = $this->pirepRepo->find($id);
|
||||
$this->checkCancelled($pirep);
|
||||
|
||||
Log::debug('Posting ACARS event, PIREP: ' . $id, $request->post());
|
||||
Log::debug('Posting ACARS event, PIREP: '.$id, $request->post());
|
||||
|
||||
$count = 0;
|
||||
$logs = $request->post('events');
|
||||
foreach ($logs as $log) {
|
||||
|
||||
$log['pirep_id'] = $id;
|
||||
$log['type'] = AcarsType::LOG;
|
||||
$log['log'] = $log['event'];
|
||||
@ -441,24 +444,25 @@ class PirepController extends RestController
|
||||
++$count;
|
||||
}
|
||||
|
||||
return $this->message($count . ' logs added', $count);
|
||||
return $this->message($count.' logs added', $count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new comment
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
||||
*/
|
||||
public function comments_get($id, Request $request)
|
||||
{
|
||||
$pirep = $this->pirepRepo->find($id);
|
||||
|
||||
return PirepCommentResource::collection($pirep->comments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new comment
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param CommentRequest $request
|
||||
* @return PirepCommentResource
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
@ -480,7 +484,7 @@ class PirepController extends RestController
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
||||
* @throws \UnexpectedValueException
|
||||
@ -490,11 +494,12 @@ class PirepController extends RestController
|
||||
{
|
||||
$pirep = $this->pirepRepo->find($id);
|
||||
$transactions = $this->journalRepo->getAllForObject($pirep);
|
||||
|
||||
return JournalTransactionResource::collection($transactions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
||||
* @throws \UnexpectedValueException
|
||||
@ -509,11 +514,12 @@ class PirepController extends RestController
|
||||
|
||||
$pirep->refresh();
|
||||
$transactions = $this->journalRepo->getAllForObject($pirep);
|
||||
|
||||
return JournalTransactionResource::collection($transactions['transactions']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
||||
*/
|
||||
@ -523,13 +529,13 @@ class PirepController extends RestController
|
||||
|
||||
return AcarsRouteResource::collection(Acars::where([
|
||||
'pirep_id' => $id,
|
||||
'type' => AcarsType::ROUTE
|
||||
'type' => AcarsType::ROUTE
|
||||
])->orderBy('order', 'asc')->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Post the ROUTE for a PIREP, can be done from the ACARS log
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param RouteRequest $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \App\Exceptions\PirepCancelled
|
||||
@ -545,7 +551,7 @@ class PirepController extends RestController
|
||||
|
||||
$count = 0;
|
||||
$route = $request->post('route', []);
|
||||
foreach($route as $position) {
|
||||
foreach ($route as $position) {
|
||||
$position['pirep_id'] = $id;
|
||||
$position['type'] = AcarsType::ROUTE;
|
||||
|
||||
@ -555,11 +561,11 @@ class PirepController extends RestController
|
||||
++$count;
|
||||
}
|
||||
|
||||
return $this->message($count . ' points added', $count);
|
||||
return $this->message($count.' points added', $count);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \Exception
|
||||
@ -570,7 +576,7 @@ class PirepController extends RestController
|
||||
|
||||
Acars::where([
|
||||
'pirep_id' => $id,
|
||||
'type' => AcarsType::ROUTE
|
||||
'type' => AcarsType::ROUTE
|
||||
])->delete();
|
||||
|
||||
return $this->message('Route deleted');
|
||||
|
@ -3,12 +3,17 @@
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Resources\Setting as SettingResource;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Repositories\SettingRepository;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SettingsController extends RestController
|
||||
/**
|
||||
* Class SettingsController
|
||||
* @package App\Http\Controllers\Api
|
||||
*/
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
protected $settingRepo;
|
||||
private $settingRepo;
|
||||
|
||||
/**
|
||||
* SettingsController constructor.
|
||||
|
@ -2,9 +2,14 @@
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Interfaces\Controller;
|
||||
use PragmaRX\Version\Package\Facade as Version;
|
||||
|
||||
class StatusController extends RestController
|
||||
/**
|
||||
* Class StatusController
|
||||
* @package App\Http\Controllers\Api
|
||||
*/
|
||||
class StatusController extends Controller
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
@ -13,7 +18,7 @@ class StatusController extends RestController
|
||||
{
|
||||
return response()->json([
|
||||
'version' => Version::compact(),
|
||||
'php' => PHP_VERSION,
|
||||
'php' => PHP_VERSION,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,12 @@
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Resources\Bid as BidResource;
|
||||
use App\Http\Resources\Flight as FlightResource;
|
||||
use App\Http\Resources\Pirep as PirepResource;
|
||||
use App\Http\Resources\Subfleet as SubfleetResource;
|
||||
use App\Http\Resources\User as UserResource;
|
||||
use App\Models\Enums\PirepState;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Models\Bid;
|
||||
use App\Models\Enums\PirepState;
|
||||
use App\Repositories\Criteria\WhereCriteria;
|
||||
use App\Repositories\FlightRepository;
|
||||
use App\Repositories\PirepRepository;
|
||||
@ -21,24 +21,27 @@ use Illuminate\Http\Request;
|
||||
use Prettus\Repository\Criteria\RequestCriteria;
|
||||
use Prettus\Repository\Exceptions\RepositoryException;
|
||||
|
||||
|
||||
class UserController extends RestController
|
||||
/**
|
||||
* Class UserController
|
||||
* @package App\Http\Controllers\Api
|
||||
*/
|
||||
class UserController extends Controller
|
||||
{
|
||||
protected $flightRepo,
|
||||
$flightSvc,
|
||||
$pirepRepo,
|
||||
$subfleetRepo,
|
||||
$userRepo,
|
||||
$userSvc;
|
||||
private $flightRepo,
|
||||
$flightSvc,
|
||||
$pirepRepo,
|
||||
$subfleetRepo,
|
||||
$userRepo,
|
||||
$userSvc;
|
||||
|
||||
/**
|
||||
* UserController constructor.
|
||||
* @param FlightRepository $flightRepo
|
||||
* @param FlightService $flightSvc
|
||||
* @param PirepRepository $pirepRepo
|
||||
* @param FlightRepository $flightRepo
|
||||
* @param FlightService $flightSvc
|
||||
* @param PirepRepository $pirepRepo
|
||||
* @param SubfleetRepository $subfleetRepo
|
||||
* @param UserRepository $userRepo
|
||||
* @param UserService $userSvc
|
||||
* @param UserRepository $userRepo
|
||||
* @param UserService $userSvc
|
||||
*/
|
||||
public function __construct(
|
||||
FlightRepository $flightRepo,
|
||||
@ -106,11 +109,12 @@ class UserController extends RestController
|
||||
$flight_id = $request->input('flight_id');
|
||||
$flight = $this->flightRepo->find($flight_id);
|
||||
$bid = $this->flightSvc->addBid($flight, $user);
|
||||
|
||||
return new BidResource($bid);
|
||||
}
|
||||
|
||||
if ($request->isMethod('DELETE')) {
|
||||
if($request->filled('bid_id')) {
|
||||
if ($request->filled('bid_id')) {
|
||||
$bid = Bid::findOrFail($request->input('bid_id'));
|
||||
$flight_id = $bid->flight_id;
|
||||
} else {
|
||||
@ -123,6 +127,7 @@ class UserController extends RestController
|
||||
|
||||
# Return the flights they currently have bids on
|
||||
$bids = Bid::where(['user_id' => $user->id])->get();
|
||||
|
||||
return BidResource::collection($bids);
|
||||
}
|
||||
|
||||
@ -152,7 +157,7 @@ class UserController extends RestController
|
||||
'user_id' => $this->getUserId($request),
|
||||
];
|
||||
|
||||
if(filled($request->query('state'))) {
|
||||
if (filled($request->query('state'))) {
|
||||
$where['state'] = $request->query('state');
|
||||
} else {
|
||||
$where[] = ['state', '!=', PirepState::CANCELLED];
|
||||
|
@ -2,9 +2,13 @@
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Interfaces\Controller;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
/**
|
||||
* Class ForgotPasswordController
|
||||
* @package App\Http\Controllers\Auth
|
||||
*/
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
use SendsPasswordResetEmails;
|
||||
|
@ -2,13 +2,17 @@
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Models\Enums\UserState;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class LoginController
|
||||
* @package App\Http\Controllers\Auth
|
||||
*/
|
||||
class LoginController extends Controller
|
||||
{
|
||||
use AuthenticatesUsers;
|
||||
@ -44,17 +48,16 @@ class LoginController extends Controller
|
||||
$user->save();
|
||||
|
||||
// TODO: How to handle ON_LEAVE?
|
||||
if($user->state !== UserState::ACTIVE) {
|
||||
|
||||
Log::info('Trying to login '. $user->pilot_id .', state '
|
||||
. UserState::label($user->state));
|
||||
if ($user->state !== UserState::ACTIVE) {
|
||||
Log::info('Trying to login '.$user->pilot_id.', state '
|
||||
.UserState::label($user->state));
|
||||
|
||||
// Log them out
|
||||
$this->guard()->logout();
|
||||
$request->session()->invalidate();
|
||||
|
||||
// Redirect to one of the error pages
|
||||
if($user->state === UserState::PENDING) {
|
||||
if ($user->state === UserState::PENDING) {
|
||||
return view('auth.pending');
|
||||
} elseif ($user->state === UserState::REJECTED) {
|
||||
return view('auth.rejected');
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Facades\Utils;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Models\Enums\UserState;
|
||||
use App\Models\User;
|
||||
use App\Repositories\AirlineRepository;
|
||||
@ -16,6 +16,10 @@ use Jackiedo\Timezonelist\Facades\Timezonelist;
|
||||
use Log;
|
||||
use Validator;
|
||||
|
||||
/**
|
||||
* Class RegisterController
|
||||
* @package App\Http\Controllers\Auth
|
||||
*/
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
use RegistersUsers;
|
||||
@ -26,15 +30,15 @@ class RegisterController extends Controller
|
||||
*/
|
||||
protected $redirectTo = '/';
|
||||
|
||||
protected $airlineRepo,
|
||||
$airportRepo,
|
||||
$userService;
|
||||
private $airlineRepo,
|
||||
$airportRepo,
|
||||
$userService;
|
||||
|
||||
/**
|
||||
* RegisterController constructor.
|
||||
* @param AirlineRepository $airlineRepo
|
||||
* @param AirportRepository $airportRepo
|
||||
* @param UserService $userService
|
||||
* @param UserService $userService
|
||||
*/
|
||||
public function __construct(
|
||||
AirlineRepository $airlineRepo,
|
||||
@ -58,25 +62,25 @@ class RegisterController extends Controller
|
||||
$airlines = $this->airlineRepo->selectBoxList();
|
||||
|
||||
return view('auth.register', [
|
||||
'airports' => $airports,
|
||||
'airlines' => $airlines,
|
||||
'airports' => $airports,
|
||||
'airlines' => $airlines,
|
||||
'timezones' => Timezonelist::toArray(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
$rules = [
|
||||
'name' => 'required|max:255',
|
||||
'email' => 'required|email|max:255|unique:users',
|
||||
'airline_id' => 'required',
|
||||
'name' => 'required|max:255',
|
||||
'email' => 'required|email|max:255|unique:users',
|
||||
'airline_id' => 'required',
|
||||
'home_airport_id' => 'required',
|
||||
'password' => 'required|min:5|confirmed',
|
||||
'password' => 'required|min:5|confirmed',
|
||||
];
|
||||
|
||||
if (config('captcha.enabled')) {
|
||||
@ -96,13 +100,13 @@ class RegisterController extends Controller
|
||||
protected function create(array $data)
|
||||
{
|
||||
$opts = [
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'api_key' => Utils::generateApiKey(),
|
||||
'airline_id' => $data['airline_id'],
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'api_key' => Utils::generateApiKey(),
|
||||
'airline_id' => $data['airline_id'],
|
||||
'home_airport_id' => $data['home_airport_id'],
|
||||
'curr_airport_id' => $data['home_airport_id'],
|
||||
'password' => Hash::make($data['password'])
|
||||
'password' => Hash::make($data['password'])
|
||||
];
|
||||
|
||||
$user = User::create($opts);
|
||||
@ -122,25 +126,26 @@ class RegisterController extends Controller
|
||||
public function register(Request $request)
|
||||
{
|
||||
$rules = [
|
||||
'name' => 'required',
|
||||
'email' => 'required|email|unique:users,email',
|
||||
'airline_id' => 'required',
|
||||
'name' => 'required',
|
||||
'email' => 'required|email|unique:users,email',
|
||||
'airline_id' => 'required',
|
||||
'home_airport_id' => 'required',
|
||||
'password' => 'required|confirmed'
|
||||
'password' => 'required|confirmed'
|
||||
];
|
||||
|
||||
if(config('captcha.enabled')) {
|
||||
if (config('captcha.enabled')) {
|
||||
$rules['g-recaptcha-response'] = 'required|captcha';
|
||||
}
|
||||
|
||||
$this->validate(request(), $rules);
|
||||
|
||||
$user = $this->create($request->all());
|
||||
if($user->state === UserState::PENDING) {
|
||||
if ($user->state === UserState::PENDING) {
|
||||
return view('auth.pending');
|
||||
}
|
||||
|
||||
$this->guard()->login($user);
|
||||
|
||||
return redirect('/dashboard');
|
||||
}
|
||||
}
|
||||
|
@ -2,19 +2,23 @@
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Interfaces\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* Class ResetPasswordController
|
||||
* @package App\Http\Controllers\Auth
|
||||
*/
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
protected $redirectTo = '/login';
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
protected $redirectTo = '/login';
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param null $token
|
||||
* @param null $token
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function showResetForm(Request $request, $token = null)
|
||||
|
@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
|
||||
/**
|
||||
* Display a view but pull it from the active skin
|
||||
* @param string $template
|
||||
* @param array $vars
|
||||
* @param array $merge_data
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function view($template, array $vars=[], $merge_data=[])
|
||||
{
|
||||
return view($template, $vars, $merge_data);
|
||||
}
|
||||
}
|
@ -2,19 +2,24 @@
|
||||
|
||||
namespace App\Http\Controllers\Frontend;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Repositories\AcarsRepository;
|
||||
use App\Services\GeoService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* Class AcarsController
|
||||
* @package App\Http\Controllers\Frontend
|
||||
*/
|
||||
class AcarsController extends Controller
|
||||
{
|
||||
private $acarsRepo, $geoSvc;
|
||||
private $acarsRepo,
|
||||
$geoSvc;
|
||||
|
||||
/**
|
||||
* AcarsController constructor.
|
||||
* @param AcarsRepository $acarsRepo
|
||||
* @param GeoService $geoSvc
|
||||
* @param GeoService $geoSvc
|
||||
*/
|
||||
public function __construct(
|
||||
AcarsRepository $acarsRepo,
|
||||
@ -33,8 +38,8 @@ class AcarsController extends Controller
|
||||
$pireps = $this->acarsRepo->getPositions();
|
||||
$positions = $this->geoSvc->getFeatureForLiveFlights($pireps);
|
||||
|
||||
return view('acars.index',[
|
||||
'pireps' => $pireps,
|
||||
return view('acars.index', [
|
||||
'pireps' => $pireps,
|
||||
'positions' => $positions,
|
||||
]);
|
||||
}
|
||||
|
@ -2,26 +2,26 @@
|
||||
|
||||
namespace App\Http\Controllers\Frontend;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Repositories\PirepRepository;
|
||||
use App\Repositories\UserRepository;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
/**
|
||||
* Class DashboardController
|
||||
* @package App\Http\Controllers\Frontend
|
||||
*/
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
private $pirepRepo, $userRepo;
|
||||
private $pirepRepo;
|
||||
|
||||
/**
|
||||
* DashboardController constructor.
|
||||
* @param PirepRepository $pirepRepo
|
||||
* @param UserRepository $userRepo
|
||||
*/
|
||||
public function __construct(
|
||||
PirepRepository $pirepRepo,
|
||||
UserRepository $userRepo
|
||||
PirepRepository $pirepRepo
|
||||
) {
|
||||
$this->pirepRepo = $pirepRepo;
|
||||
$this->userRepo = $userRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -34,7 +34,8 @@ class DashboardController extends Controller
|
||||
|
||||
try {
|
||||
$last_pirep = $this->pirepRepo->find($user->last_pirep_id);
|
||||
} catch(\Exception $e) { }
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
|
||||
return view('dashboard.index', [
|
||||
'user' => $user,
|
||||
|
@ -2,19 +2,22 @@
|
||||
|
||||
namespace App\Http\Controllers\Frontend;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Interfaces\Controller;
|
||||
use App\Models\Bid;
|
||||
use App\Repositories\AirlineRepository;
|
||||
use App\Repositories\AirportRepository;
|
||||
use App\Repositories\Criteria\WhereCriteria;
|
||||
use App\Repositories\FlightRepository;
|
||||
use App\Services\FlightService;
|
||||
use App\Services\GeoService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Log;
|
||||
use Prettus\Repository\Exceptions\RepositoryException;
|
||||
|
||||
/**
|
||||
* Class FlightController
|
||||
* @package App\Http\Controllers\Frontend
|
||||
*/
|
||||
class FlightController extends Controller
|
||||
{
|
||||
private $airlineRepo,
|
||||
@ -26,21 +29,19 @@ class FlightController extends Controller
|
||||
* FlightController constructor.
|
||||
* @param AirlineRepository $airlineRepo
|
||||
* @param AirportRepository $airportRepo
|
||||
* @param FlightRepository $flightRepo
|
||||
* @param FlightService $flightSvc
|
||||
* @param GeoService $geoSvc
|
||||
* @param FlightRepository $flightRepo
|
||||
* @param GeoService $geoSvc
|
||||
*/
|
||||
public function __construct(
|
||||
AirlineRepository $airlineRepo,
|
||||
AirportRepository $airportRepo,
|
||||
FlightRepository $flightRepo,
|
||||
FlightService $flightSvc,
|
||||
GeoService $geoSvc
|
||||
) {
|
||||
)
|
||||
{
|
||||
$this->airlineRepo = $airlineRepo;
|
||||
$this->airportRepo = $airportRepo;
|
||||
$this->flightRepo = $flightRepo;
|
||||
$this->flightSvc = $flightSvc;
|
||||
$this->geoSvc = $geoSvc;
|
||||
}
|
||||
|
||||
@ -66,13 +67,13 @@ class FlightController extends Controller
|
||||
$flights = $this->flightRepo->paginate();
|
||||
|
||||
$saved_flights = Bid::where('user_id', Auth::id())
|
||||
->pluck('flight_id')->toArray();
|
||||
->pluck('flight_id')->toArray();
|
||||
|
||||
return view('flights.index', [
|
||||
'airlines' => $this->airlineRepo->selectBoxList(true),
|
||||
'airports' => $this->airportRepo->selectBoxList(true),
|
||||
'flights' => $flights,
|
||||
'saved' => $saved_flights,
|
||||
'flights' => $flights,
|
||||
'saved' => $saved_flights,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -87,13 +88,13 @@ class FlightController extends Controller
|
||||
$flights = $this->flightRepo->searchCriteria($request)->paginate();
|
||||
|
||||
$saved_flights = Bid::where('user_id', Auth::id())
|
||||
->pluck('flight_id')->toArray();
|
||||
->pluck('flight_id')->toArray();
|
||||
|
||||
return view('flights.index', [
|
||||
'airlines' => $this->airlineRepo->selectBoxList(true),
|
||||
'airports' => $this->airportRepo->selectBoxList(true),
|
||||
'flights' => $flights,
|
||||
'saved' => $saved_flights,
|
||||
'flights' => $flights,
|
||||
'saved' => $saved_flights,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -107,13 +108,14 @@ class FlightController extends Controller
|
||||
$flight = $this->flightRepo->find($id);
|
||||
if (empty($flight)) {
|
||||
Flash::error('Flight not found!');
|
||||
|
||||
return redirect(route('frontend.dashboard.index'));
|
||||
}
|
||||
|
||||
$map_features = $this->geoSvc->flightGeoJson($flight);
|
||||
|
||||
return view('flights.show', [
|
||||
'flight' => $flight,
|
||||
'flight' => $flight,
|
||||
'map_features' => $map_features,
|
||||
]);
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user