diff --git a/app/Console/Commands/Install.php b/app/Console/Commands/Install.php index 46207a9a0..5e3602ea8 100644 --- a/app/Console/Commands/Install.php +++ b/app/Console/Commands/Install.php @@ -57,7 +57,7 @@ class Install extends Command public function handle() { if (($missing_options = $this->getMissingOptions()) && $this->option(self::OPT_NO_INTERACTION)) { - $this->line('❌ Some options are missing and --no-interaction is present. Please run the following command for more informations :'); + $this->line('❌ Some options are missing and --no-interaction is present. Please run the following command for more information :'); $this->line('❌ php artisan help install'); $this->line('❌ Missing options are : ' . implode(', ', $missing_options)); @@ -111,6 +111,8 @@ class Install extends Command 'OPT_ADMIN_PASSWORD' ]; + $allowed_empty = ['db_password', 'db_prefix']; + foreach ($contants as $const) { $option = constant("self::$const"); @@ -118,14 +120,15 @@ class Install extends Command $this->$property = $this->option($option); - if (empty($this->$property)) { - // Allow empty password - if ($property == 'db_password') { - continue; - } - - $missing_options[] = $option; + if (!empty($this->$property)) { + continue; } + + if (in_array($property, $allowed_empty)) { + continue; + } + + $missing_options[] = $option; } return $missing_options; diff --git a/app/Console/Commands/InstallRefresh.php b/app/Console/Commands/InstallRefresh.php new file mode 100644 index 000000000..fc2928ac7 --- /dev/null +++ b/app/Console/Commands/InstallRefresh.php @@ -0,0 +1,58 @@ +info('Resetting migrations'); + $this->callSilent('migrate:reset', [ + '--force' => true, + ]); + + $this->info('Installing Akaunting'); + $this->callSilent('install', [ + '--db-host' => env('DB_HOST'), + '--db-port' => env('DB_PORT'), + '--db-name' => env('DB_DATABASE'), + '--db-username' => env('DB_USERNAME'), + '--db-password' => env('DB_PASSWORD'), + '--db-prefix' => env('DB_PREFIX'), + '--company-name' => $company->name, + '--company-email' => $company->email, + '--admin-email' => $user->email, + '--admin-password' => $this->option('admin-password'), + '--locale' => $company->locale, + '--no-interaction' => true, + ]); + + $this->info('Installation refreshed'); + } +}