phpvms/app/Console/Commands/Install.php

78 lines
1.8 KiB
PHP
Raw Normal View History

<?php
namespace App\Console\Commands;
2017-12-30 00:23:42 +08:00
use App\Console\BaseCommand;
2017-12-30 00:23:42 +08:00
class Install extends BaseCommand
{
2017-07-14 06:52:08 +08:00
protected $signature = 'phpvms:install
{--update}
{--airline-name?}
{--airline-code?}';
protected $description = 'Install or update phpVMS';
public function __construct()
{
parent::__construct();
}
public function handle()
{
$this->info('Installing phpVMS...');
$this->setupDatabase();
2017-07-14 06:52:08 +08:00
# Only run these if we're doing an initial install
if(!$this->option('update')) {
2017-12-04 00:55:01 +08:00
$this->writeLocalConfig();
2017-07-14 06:52:08 +08:00
$this->initialData();
}
}
/**
2017-12-04 00:55:01 +08:00
* 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');
}
2017-07-14 06:52:08 +08:00
$this->info('Running database migrations...');
2017-12-30 06:56:46 +08:00
$this->call('migrate');
# TODO: Call initial seed data, for the groups and other supporting data
}
/**
2017-12-04 00:55:01 +08:00
* Write a local config file
*/
protected function writeLocalConfig()
{
}
/**
* Set an initial airline and admin user/password
*/
protected function initialData()
{
2017-07-14 06:52:08 +08:00
# 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
}
}