Fixed merge
This commit is contained in:
44
app/Console/Commands/ComposerCommand.php
Normal file
44
app/Console/Commands/ComposerCommand.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\Command;
|
||||
use Artisan;
|
||||
|
||||
/**
|
||||
* Class ComposerCommand
|
||||
* @package App\Console\Commands
|
||||
*/
|
||||
class ComposerCommand extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:composer {cmd}';
|
||||
protected $description = 'Composer related tasks';
|
||||
|
||||
/**
|
||||
* Run composer update related commands
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
switch(trim($this->argument('cmd')))
|
||||
{
|
||||
case 'post-update':
|
||||
$this->postUpdate();
|
||||
break;
|
||||
default:
|
||||
$this->error('Command exists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Any composer post update tasks
|
||||
*/
|
||||
protected function postUpdate(): void
|
||||
{
|
||||
if (config('app.env') === 'dev') {
|
||||
if (class_exists(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class)) {
|
||||
Artisan::call('ide-helper:generate');
|
||||
Artisan::call('ide-helper:meta');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ use App\Models\Airline;
|
||||
use App\Models\Pirep;
|
||||
use App\Models\User;
|
||||
use App\Services\AwardService;
|
||||
use Artisan;
|
||||
use DB;
|
||||
use PDO;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\Command;
|
||||
|
||||
/**
|
||||
* Class Install
|
||||
* @package App\Console\Commands
|
||||
*/
|
||||
class Install extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:install
|
||||
{--update}
|
||||
{--airline-name?}
|
||||
{--airline-code?}';
|
||||
|
||||
protected $description = 'Install or update phpVMS';
|
||||
|
||||
/**
|
||||
* Install constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Installing phpVMS...');
|
||||
|
||||
$this->setupDatabase();
|
||||
|
||||
# Only run these if we're doing an initial install
|
||||
if (!$this->option('update')) {
|
||||
$this->writeLocalConfig();
|
||||
$this->initialData();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database and run the migrations
|
||||
* Only call the database creation if we're not
|
||||
* explicitly trying to upgrade
|
||||
*/
|
||||
protected function setupDatabase()
|
||||
{
|
||||
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(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an initial airline and admin user/password
|
||||
*/
|
||||
protected function initialData()
|
||||
{
|
||||
# TODO: Prompt for initial airline info
|
||||
$airline_name = $this->option('airline-name');
|
||||
if (!$airline_name) {
|
||||
$airline_name = $this->ask('Enter your airline name');
|
||||
}
|
||||
|
||||
$airline_code = $this->option('airline-code');
|
||||
if (!$airline_code) {
|
||||
$airline_code = $this->ask('Enter your airline code');
|
||||
}
|
||||
# TODO: Prompt for admin user/password
|
||||
}
|
||||
}
|
||||
@@ -15,14 +15,13 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
protected $commands = [
|
||||
Commands\AcarsReplay::class,
|
||||
/*Commands\AcarsReplay::class,
|
||||
Commands\CreateDatabase::class,
|
||||
Commands\DevCommands::class,
|
||||
Commands\YamlImport::class,
|
||||
Commands\ImportFromClassic::class,
|
||||
Commands\Install::class,
|
||||
Commands\NavdataImport::class,
|
||||
Commands\TestApi::class,
|
||||
Commands\TestApi::class,*/
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
32
app/Exceptions/InternalError.php
Normal file
32
app/Exceptions/InternalError.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Validator;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Show an internal error, bug piggyback off of the validation
|
||||
* exception type - this has a place to show up in the UI as a
|
||||
* flash message.
|
||||
* @package App\Exceptions
|
||||
*/
|
||||
class InternalError extends ValidationException
|
||||
{
|
||||
protected const FLASH_FIELD_NAME = 'internal_error_message';
|
||||
|
||||
/**
|
||||
* InternalError constructor.
|
||||
* @param string|null $message
|
||||
* @param null $field
|
||||
*/
|
||||
final public function __construct(string $message = null, $field = null)
|
||||
{
|
||||
Log::error($message);
|
||||
$validator = Validator::make([], []);
|
||||
$validator->errors()->add($field ?? static::FLASH_FIELD_NAME, $message);
|
||||
|
||||
parent::__construct($validator);
|
||||
}
|
||||
}
|
||||
@@ -49,22 +49,33 @@ class AircraftController extends Controller
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$this->aircraftRepo->pushCriteria(new RequestCriteria($request));
|
||||
$aircraft = $this->aircraftRepo->orderBy('registration', 'asc')->all();
|
||||
// If subfleet ID is passed part of the query string, then only
|
||||
// show the aircraft that are in that subfleet
|
||||
$w = [];
|
||||
if($request->filled('subfleet')) {
|
||||
$w['subfleet_id'] = $request->input('subfleet');
|
||||
}
|
||||
|
||||
$aircraft = $this->aircraftRepo->whereOrder($w, 'registration', 'asc');
|
||||
$aircraft = $aircraft->all();
|
||||
|
||||
return view('admin.aircraft.index', [
|
||||
'aircraft' => $aircraft
|
||||
'aircraft' => $aircraft,
|
||||
'subfleet_id' => $request->input('subfleet'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new Aircraft.
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function create()
|
||||
public function create(Request $request)
|
||||
{
|
||||
return view('admin.aircraft.create', [
|
||||
'subfleets' => Subfleet::all()->pluck('name', 'id'),
|
||||
'statuses' => AircraftStatus::select(true),
|
||||
'subfleet_id' => $request->query('subfleet')
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -398,21 +398,25 @@ class FlightController extends Controller
|
||||
if ($request->isMethod('post')) {
|
||||
Log::info('Adding new flight field, flight: '.$flight_id, $request->input());
|
||||
|
||||
$field = new FlightFieldValue;
|
||||
$field = new FlightFieldValue();
|
||||
$field->flight_id = $flight_id;
|
||||
$field->name = $request->input('name');
|
||||
$field->value = $request->input('value');
|
||||
$field->save();
|
||||
} elseif ($request->isMethod('put')) {
|
||||
Log::info('Updating flight field, flight: '.$flight_id, $request->input());
|
||||
$field = FlightFieldValue::where('name', $request->input('name'))->first();
|
||||
$field = FlightFieldValue::where([
|
||||
'name' => $request->input('name'),
|
||||
'flight_id' => $flight_id,
|
||||
])->first();
|
||||
|
||||
if(!$field) {
|
||||
Log::info('Field not found, creating new');
|
||||
$field = new FlightFieldValue();
|
||||
$field->flight_id = $flight_id;
|
||||
$field->name = $request->input('name');
|
||||
}
|
||||
|
||||
$field->flight_id = $flight_id;
|
||||
$field->value = $request->input('value');
|
||||
$field->save();
|
||||
// update the field value
|
||||
|
||||
@@ -46,5 +46,14 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
# Only dev environment stuff
|
||||
if ($this->app->environment() === 'dev') {
|
||||
|
||||
# Only load the IDE helper if it's included. This lets use distribute the
|
||||
# package without any dev dependencies
|
||||
if (class_exists(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class)) {
|
||||
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ class ImportService extends Service
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw a validation error back up because it will automatically show
|
||||
* itself under the CSV file upload, and nothing special needs to be done
|
||||
* @param $error
|
||||
* @param $e
|
||||
* @throws ValidationException
|
||||
@@ -72,13 +74,15 @@ class ImportService extends Service
|
||||
/**
|
||||
* Run the actual importer, pass in one of the Import classes which implements
|
||||
* the ImportExport interface
|
||||
* @param Reader $reader
|
||||
* @param $file_path
|
||||
* @param ImportExport $importer
|
||||
* @return array
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function runImport(Reader $reader, ImportExport $importer): array
|
||||
protected function runImport($file_path, ImportExport $importer): array
|
||||
{
|
||||
$reader = $this->openCsv($file_path);
|
||||
|
||||
$cols = $importer->getColumns();
|
||||
$first_header = $cols[0];
|
||||
|
||||
@@ -126,13 +130,8 @@ class ImportService extends Service
|
||||
# TODO: delete airports
|
||||
}
|
||||
|
||||
$reader = $this->openCsv($csv_file);
|
||||
if (!$reader) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$importer = new AircraftImporter();
|
||||
return $this->runImport($reader, $importer);
|
||||
return $this->runImport($csv_file, $importer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,13 +147,8 @@ class ImportService extends Service
|
||||
Airport::truncate();
|
||||
}
|
||||
|
||||
$reader = $this->openCsv($csv_file);
|
||||
if (!$reader) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$importer = new AirportImporter();
|
||||
return $this->runImport($reader, $importer);
|
||||
return $this->runImport($csv_file, $importer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,13 +164,8 @@ class ImportService extends Service
|
||||
Expense::truncate();
|
||||
}
|
||||
|
||||
$reader = $this->openCsv($csv_file);
|
||||
if (!$reader) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$importer = new ExpenseImporter();
|
||||
return $this->runImport($reader, $importer);
|
||||
return $this->runImport($csv_file, $importer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,14 +181,8 @@ class ImportService extends Service
|
||||
# TODO: Delete all from: fares
|
||||
}
|
||||
|
||||
$reader = $this->openCsv($csv_file);
|
||||
if (!$reader) {
|
||||
# TODO: Throw an error
|
||||
return false;
|
||||
}
|
||||
|
||||
$importer = new FareImporter();
|
||||
return $this->runImport($reader, $importer);
|
||||
return $this->runImport($csv_file, $importer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,14 +198,8 @@ class ImportService extends Service
|
||||
# TODO: Delete all from: flights, flight_field_values
|
||||
}
|
||||
|
||||
$reader = $this->openCsv($csv_file);
|
||||
if (!$reader) {
|
||||
# TODO: Throw an error
|
||||
return false;
|
||||
}
|
||||
|
||||
$importer = new FlightImporter();
|
||||
return $this->runImport($reader, $importer);
|
||||
return $this->runImport($csv_file, $importer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -238,13 +215,7 @@ class ImportService extends Service
|
||||
# TODO: Cleanup subfleet data
|
||||
}
|
||||
|
||||
$reader = $this->openCsv($csv_file);
|
||||
if (!$reader) {
|
||||
# TODO: Throw an error
|
||||
return false;
|
||||
}
|
||||
|
||||
$importer = new SubfleetImporter();
|
||||
return $this->runImport($reader, $importer);
|
||||
return $this->runImport($csv_file, $importer);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user