Multiple ticket crash fixes (#347)
* Fix for initial seed data not being run during install closes #346 * StyleCI keepin' me honest * Tooltips for ranks
This commit is contained in:
parent
e12188b7d3
commit
5cce1b3040
@ -9,7 +9,8 @@ use App\Models\Pirep;
|
||||
use App\Models\User;
|
||||
use App\Services\AwardService;
|
||||
use App\Services\DatabaseService;
|
||||
use DB;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use PDO;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
@ -46,12 +47,13 @@ class DevCommands extends Command
|
||||
}
|
||||
|
||||
$commands = [
|
||||
'list-awards' => 'listAwardClasses',
|
||||
'clear-acars' => 'clearAcars',
|
||||
'clear-users' => 'clearUsers',
|
||||
'compile-assets' => 'compileAssets',
|
||||
'db-attrs' => 'dbAttrs',
|
||||
'list-awards' => 'listAwardClasses',
|
||||
'manual-insert' => 'manualInsert',
|
||||
'reset-install' => 'resetInstall',
|
||||
'xml-to-yaml' => 'xmlToYaml',
|
||||
];
|
||||
|
||||
@ -212,4 +214,33 @@ class DevCommands extends Command
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all of the tables, etc from the database, for a clean install
|
||||
*/
|
||||
protected function resetInstall(): void
|
||||
{
|
||||
$confirm = $this->ask('This will erase your entire install and database, are you sure? y/n ');
|
||||
if (strtolower($confirm) !== 'y') {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (config('database.default') === 'mysql') {
|
||||
DB::statement('SET foreign_key_checks=0');
|
||||
}
|
||||
|
||||
$this->info('Dropping all tables');
|
||||
$tables = DB::connection()->getDoctrineSchemaManager()->listTableNames();
|
||||
foreach ($tables as $table) {
|
||||
Schema::dropIfExists($table);
|
||||
}
|
||||
|
||||
$this->info('Deleting config file');
|
||||
unlink('config.php');
|
||||
|
||||
$this->info('Deleting env file');
|
||||
unlink('env.php');
|
||||
|
||||
$this->info('Done!');
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
#
|
||||
# Initial minimal data required. You probably don't
|
||||
# want to modify or erase any of this here
|
||||
#
|
||||
|
||||
airports:
|
||||
- id: KAUS
|
||||
iata: AUS
|
||||
icao: KAUS
|
||||
name: Austin-Bergstrom
|
||||
location: Austin, Texas, USA
|
||||
country: United States
|
||||
timezone: America/Chicago
|
||||
lat: 30.1945278
|
||||
lon: -97.6698889
|
||||
hub: 1
|
@ -8,13 +8,14 @@ use App\Models\User;
|
||||
use App\Repositories\AirlineRepository;
|
||||
use App\Services\AnalyticsService;
|
||||
use App\Services\Installer\MigrationService;
|
||||
use App\Services\Installer\SeederService;
|
||||
use App\Services\UserService;
|
||||
use App\Support\Countries;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Log;
|
||||
use Modules\Installer\Services\ConfigService;
|
||||
use Modules\Installer\Services\DatabaseService;
|
||||
use Modules\Installer\Services\RequirementsService;
|
||||
@ -28,21 +29,23 @@ class InstallerController extends Controller
|
||||
{
|
||||
private $airlineRepo,
|
||||
$analyticsSvc,
|
||||
$dbService,
|
||||
$envService,
|
||||
$dbSvc,
|
||||
$envSvc,
|
||||
$migrationSvc,
|
||||
$reqService,
|
||||
$reqSvc,
|
||||
$seederSvc,
|
||||
$userService;
|
||||
|
||||
/**
|
||||
* InstallerController constructor.
|
||||
* @param AirlineRepository $airlineRepo
|
||||
* @param AnalyticsService $analyticsSvc
|
||||
* @param DatabaseService $dbService
|
||||
* @param ConfigService $envService
|
||||
* @param MigrationService $migrationSvc
|
||||
* @param RequirementsService $reqService
|
||||
* @param UserService $userService
|
||||
* @param AirlineRepository $airlineRepo
|
||||
* @param AnalyticsService $analyticsSvc
|
||||
* @param DatabaseService $dbService
|
||||
* @param ConfigService $envService
|
||||
* @param MigrationService $migrationSvc
|
||||
* @param RequirementsService $reqSvc
|
||||
* @param SeederService $seederSvc
|
||||
* @param UserService $userService
|
||||
*/
|
||||
public function __construct(
|
||||
AirlineRepository $airlineRepo,
|
||||
@ -50,15 +53,17 @@ class InstallerController extends Controller
|
||||
DatabaseService $dbService,
|
||||
ConfigService $envService,
|
||||
MigrationService $migrationSvc,
|
||||
RequirementsService $reqService,
|
||||
RequirementsService $reqSvc,
|
||||
SeederService $seederSvc,
|
||||
UserService $userService
|
||||
) {
|
||||
$this->airlineRepo = $airlineRepo;
|
||||
$this->analyticsSvc = $analyticsSvc;
|
||||
$this->dbService = $dbService;
|
||||
$this->envService = $envService;
|
||||
$this->dbSvc = $dbService;
|
||||
$this->envSvc = $envService;
|
||||
$this->migrationSvc = $migrationSvc;
|
||||
$this->reqService = $reqService;
|
||||
$this->reqSvc = $reqSvc;
|
||||
$this->seederSvc = $seederSvc;
|
||||
$this->userService = $userService;
|
||||
}
|
||||
/**
|
||||
@ -75,7 +80,7 @@ class InstallerController extends Controller
|
||||
|
||||
protected function testDb(Request $request)
|
||||
{
|
||||
$this->dbService->checkDbConnection(
|
||||
$this->dbSvc->checkDbConnection(
|
||||
$request->post('db_conn'),
|
||||
$request->post('db_host'),
|
||||
$request->post('db_port'),
|
||||
@ -131,9 +136,9 @@ class InstallerController extends Controller
|
||||
*/
|
||||
public function step1(Request $request)
|
||||
{
|
||||
$php_version = $this->reqService->checkPHPVersion();
|
||||
$extensions = $this->reqService->checkExtensions();
|
||||
$directories = $this->reqService->checkPermissions();
|
||||
$php_version = $this->reqSvc->checkPHPVersion();
|
||||
$extensions = $this->reqSvc->checkExtensions();
|
||||
$directories = $this->reqSvc->checkPermissions();
|
||||
|
||||
# Only pass if all the items in the ext and dirs are passed
|
||||
$statuses = [
|
||||
@ -210,7 +215,7 @@ class InstallerController extends Controller
|
||||
* setup the database and stuff
|
||||
*/
|
||||
try {
|
||||
$this->envService->createConfigFiles($attrs);
|
||||
$this->envSvc->createConfigFiles($attrs);
|
||||
} catch(FileException $e) {
|
||||
Log::error('Config files failed to write');
|
||||
Log::error($e->getMessage());
|
||||
@ -234,12 +239,13 @@ class InstallerController extends Controller
|
||||
$console_out = '';
|
||||
|
||||
try {
|
||||
$console_out .= $this->dbService->setupDB();
|
||||
$console_out .= $this->dbSvc->setupDB();
|
||||
$console_out .= $this->migrationSvc->runAllMigrations();
|
||||
$this->seederSvc->syncAllSeeds();
|
||||
} catch(QueryException $e) {
|
||||
Log::error('Error on db setup: ' . $e->getMessage());
|
||||
|
||||
$this->envService->removeConfigFiles();
|
||||
$this->envSvc->removeConfigFiles();
|
||||
flash()->error($e->getMessage());
|
||||
return redirect(route('installer.step2'))->withInput();
|
||||
}
|
||||
@ -309,8 +315,6 @@ class InstallerController extends Controller
|
||||
'email' => $request->get('email'),
|
||||
'api_key' => Utils::generateApiKey(),
|
||||
'airline_id' => $airline->id,
|
||||
'home_airport_id' => 'KAUS',
|
||||
'curr_airport_id' => 'KAUS',
|
||||
'password' => Hash::make($request->get('password'))
|
||||
];
|
||||
|
||||
|
@ -12,8 +12,11 @@ return [
|
||||
'name' => '$SITE_NAME$',
|
||||
'url' => '$SITE_URL$',
|
||||
|
||||
# Don't forget to change these when live
|
||||
// When live, 'env' should be 'prod'
|
||||
'env' => 'prod',
|
||||
|
||||
// debug as true shows the Laravel debug bar, which is helpful for
|
||||
// debugging templates and other internals
|
||||
'debug' => false,
|
||||
],
|
||||
|
||||
@ -71,7 +74,7 @@ return [
|
||||
'default' => env('DB_CONNECTION', '$DB_CONN$'),
|
||||
'connections' => [
|
||||
'mysql' => [
|
||||
'host' => '$DB_HOST$',
|
||||
'host' => env('DB_HOST', '$DB_HOST$'),
|
||||
'port' => $DB_PORT$,
|
||||
'database' => '$DB_NAME$',
|
||||
'username' => '$DB_USER$',
|
||||
|
@ -50,35 +50,50 @@
|
||||
<div class="form-container-body">
|
||||
<div class="row">
|
||||
<!-- Auto Approve Acars Field -->
|
||||
<div class="form-group col-sm-4 text-center">
|
||||
<div class="form-group col-sm-4">
|
||||
<div class="checkbox">
|
||||
<label class="checkbox-inline">
|
||||
{{ Form::hidden('auto_approve_acars', false) }}
|
||||
{{ Form::checkbox('auto_approve_acars') }}
|
||||
{{ Form::label('auto_approve_acars', 'Auto Approve ACARS PIREPs') }}
|
||||
</label>
|
||||
<div style="margin-left: 10px">
|
||||
@component('admin.components.info')
|
||||
PIREPS submitted through ACARS are automatically accepted
|
||||
@endcomponent
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Auto Approve Manual Field -->
|
||||
<div class="form-group col-sm-4 text-center">
|
||||
<div class="form-group col-sm-4">
|
||||
<div class="checkbox">
|
||||
<label class="checkbox-inline">
|
||||
{{ Form::hidden('auto_approve_manual', false) }}
|
||||
{{ Form::checkbox('auto_approve_manual') }}
|
||||
{{ Form::label('auto_approve_manual', 'Auto Approve Manual PIREPs') }}
|
||||
</label>
|
||||
<div style="margin-left: 10px">
|
||||
@component('admin.components.info')
|
||||
PIREPS submitted manually are automatically accepted
|
||||
@endcomponent
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Auto Promote Field -->
|
||||
<div class="form-group col-sm-4 text-center">
|
||||
<div class="form-group col-sm-4">
|
||||
<div class="checkbox">
|
||||
<label class="checkbox-inline">
|
||||
{{ Form::hidden('auto_promote', false) }}
|
||||
{{ Form::checkbox('auto_promote') }}
|
||||
{{ Form::label('auto_promote', 'Auto Promote') }}
|
||||
</label>
|
||||
<div style="margin-left: 10px">
|
||||
@component('admin.components.info')
|
||||
When a pilot reaches these hours, they'll be upgraded to this rank
|
||||
@endcomponent
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user