From bb9c90d0a28cc85f2534762300a9aa9feef69a27 Mon Sep 17 00:00:00 2001 From: ghermans Date: Tue, 25 Feb 2020 03:29:33 +0100 Subject: [PATCH 1/5] #2525 Added locale, timezone and currency --- .env.example | 5 +++-- app/Console/Commands/install.php | 17 +++++++++++++++-- config/app.php | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index e710496ca..c3e5febd2 100644 --- a/.env.example +++ b/.env.example @@ -4,9 +4,10 @@ APP_VERSION=1.0.0 APP_KEY= APP_DEBUG=true APP_URL=http://localhost -APP_TIMEZONE='Asia/Kolkata' +APP_TIMEZONE= +APP_LOCALE= LOG_CHANNEL=stack -APP_CURRENCY=USD +APP_CURRENCY= DB_CONNECTION=mysql DB_HOST=127.0.0.1 diff --git a/app/Console/Commands/install.php b/app/Console/Commands/install.php index b1c2b3380..f8de6663f 100644 --- a/app/Console/Commands/install.php +++ b/app/Console/Commands/install.php @@ -91,17 +91,30 @@ class install extends Command File::copy('.env.example', '.env'); Artisan::call('key:generate'); $this->envUpdate('APP_URL=http://localhost', ':8000'); + + $locale = $this->choice('Please select the default locale or press enter to continue', ['ar', 'en', 'fa', 'nl', 'pt_BR'], 1); + $this->envUpdate('APP_LOCALE=', $locale); + + $TimeZones = timezone_identifiers_list(); + $timezone = $this->anticipate('Enter the default timezone', $TimeZones, date_default_timezone_get()); + $this->envUpdate('APP_TIMEZONE=', $timezone); + + $currency = $this->choice('Enter the default currency', ['USD', 'EUR'], 'USD'); + $this->envUpdate('APP_CURRENCY=', $currency); + + $this->addDatabaseDetails(); } catch (\Exception $e) { - $this->error('Error in creating .env file, please create manually and then run `php artisan migrate` again'); + $this->error('Error in creating .env file, please create it manually and then run `php artisan migrate` again'); } } public function addDatabaseDetails() { - $dbName = $this->ask('What is your database name to be used by bagisto'); + $dbName = $this->ask('What is the database name to be used by bagisto'); $dbUser = $this->anticipate('What is your database username', ['root']); $dbPass = $this->secret('What is your database password'); + $this->envUpdate('DB_DATABASE=', $dbName); $this->envUpdate('DB_USERNAME=', $dbUser); $this->envUpdate('DB_PASSWORD=', $dbPass); diff --git a/config/app.php b/config/app.php index 3a6ec6903..d86b5d4b2 100755 --- a/config/app.php +++ b/config/app.php @@ -78,7 +78,7 @@ return [ | */ - 'locale' => 'en', + 'locale' => env('APP_LOCALE', 'en'), /* |-------------------------------------------------------------------------- From 3365924529b1af56ba61f25257771356b6555e69 Mon Sep 17 00:00:00 2001 From: ghermans Date: Tue, 25 Feb 2020 03:30:13 +0100 Subject: [PATCH 2/5] #2525 updated config file --- config/app.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/app.php b/config/app.php index d86b5d4b2..2458eb26e 100755 --- a/config/app.php +++ b/config/app.php @@ -116,8 +116,8 @@ return [ | Here you may specify the base currency code for your application. | */ - - 'currency' => env('APP_CURRENCY','USD'), + + 'currency' => env('APP_CURRENCY', 'USD'), /* |-------------------------------------------------------------------------- From b9a6d2e6e9a8c91f78d6c281df880c8bb613b7e7 Mon Sep 17 00:00:00 2001 From: ghermans Date: Tue, 25 Feb 2020 03:38:36 +0100 Subject: [PATCH 3/5] #2525 fixed php docs --- app/Console/Commands/install.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/Console/Commands/install.php b/app/Console/Commands/install.php index f8de6663f..38c04f5a3 100644 --- a/app/Console/Commands/install.php +++ b/app/Console/Commands/install.php @@ -85,6 +85,9 @@ class install extends Command } } + /** + * Create a new .env file. + */ public function createEnvFile() { try { @@ -109,6 +112,9 @@ class install extends Command } } + /** + * Add the database credentials to the .env file. + */ public function addDatabaseDetails() { $dbName = $this->ask('What is the database name to be used by bagisto'); @@ -120,6 +126,9 @@ class install extends Command $this->envUpdate('DB_PASSWORD=', $dbPass); } + /** + * Update the .env values. + */ public static function envUpdate($key, $value) { $path = base_path() . '/.env'; From 5465963e9ab8197d8e99f97a2682c815808f2ab3 Mon Sep 17 00:00:00 2001 From: ghermans Date: Tue, 25 Feb 2020 03:46:39 +0100 Subject: [PATCH 4/5] #2525 fixed typo --- app/Console/Commands/install.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/install.php b/app/Console/Commands/install.php index 38c04f5a3..487ef886c 100644 --- a/app/Console/Commands/install.php +++ b/app/Console/Commands/install.php @@ -99,10 +99,10 @@ class install extends Command $this->envUpdate('APP_LOCALE=', $locale); $TimeZones = timezone_identifiers_list(); - $timezone = $this->anticipate('Enter the default timezone', $TimeZones, date_default_timezone_get()); + $timezone = $this->anticipate('Please enter the default timezone', $TimeZones, date_default_timezone_get()); $this->envUpdate('APP_TIMEZONE=', $timezone); - $currency = $this->choice('Enter the default currency', ['USD', 'EUR'], 'USD'); + $currency = $this->choice('Please enter the default currency', ['USD', 'EUR'], 'USD'); $this->envUpdate('APP_CURRENCY=', $currency); From a48fe56e376132db308015637ca2e21a70837c3f Mon Sep 17 00:00:00 2001 From: ghermans Date: Tue, 25 Feb 2020 03:57:05 +0100 Subject: [PATCH 5/5] #2525 fixed typos --- app/Console/Commands/install.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Console/Commands/install.php b/app/Console/Commands/install.php index 487ef886c..f8fe1d7c6 100644 --- a/app/Console/Commands/install.php +++ b/app/Console/Commands/install.php @@ -78,10 +78,10 @@ class install extends Command { $envExists = File::exists(base_path() . '/.env'); if (!$envExists) { - $this->info('Creating .env file'); + $this->info('Creating the environment configuration file.'); $this->createEnvFile(); } else { - $this->info('Great! .env file aready exists'); + $this->info('Great! your environment configuration file aready exists.'); } } @@ -108,7 +108,7 @@ class install extends Command $this->addDatabaseDetails(); } catch (\Exception $e) { - $this->error('Error in creating .env file, please create it manually and then run `php artisan migrate` again'); + $this->error('Error in creating .env file, please create it manually and then run `php artisan migrate` again.'); } } @@ -117,9 +117,9 @@ class install extends Command */ public function addDatabaseDetails() { - $dbName = $this->ask('What is the database name to be used by bagisto'); - $dbUser = $this->anticipate('What is your database username', ['root']); - $dbPass = $this->secret('What is your database password'); + $dbName = $this->ask('What is the database name to be used by bagisto?'); + $dbUser = $this->anticipate('What is your database username?', ['root']); + $dbPass = $this->secret('What is your database password?'); $this->envUpdate('DB_DATABASE=', $dbName); $this->envUpdate('DB_USERNAME=', $dbUser);