Merge pull request #5 from bagisto/master
This commit is contained in:
commit
6849069dcf
|
|
@ -35,7 +35,7 @@ class Order
|
|||
/* email to admin */
|
||||
$configKey = 'emails.general.notifications.emails.general.notifications.new-admin';
|
||||
if (core()->getConfigData($configKey)) {
|
||||
$this->prepareMail(env('APP_LOCALE'), new NewAdminNotification($order));
|
||||
$this->prepareMail(config('app.locale'), new NewAdminNotification($order));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
|
|
@ -112,7 +112,7 @@ class Order
|
|||
/* email to admin */
|
||||
$configKey = 'emails.general.notifications.emails.general.notifications.new-inventory-source';
|
||||
if (core()->getConfigData($configKey)) {
|
||||
$this->prepareMail(env('APP_LOCALE'), new NewInventorySourceNotification($shipment));
|
||||
$this->prepareMail(config('app.locale'), new NewInventorySourceNotification($shipment));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
|
|
@ -137,7 +137,7 @@ class Order
|
|||
/* email to admin */
|
||||
$configKey = 'emails.general.notifications.emails.general.notifications.new-admin';
|
||||
if (core()->getConfigData($configKey)) {
|
||||
$this->prepareMail(env('APP_LOCALE'), new CancelOrderAdminNotification($order));
|
||||
$this->prepareMail(config('app.locale'), new CancelOrderAdminNotification($order));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
|
|
@ -189,4 +189,4 @@ class Order
|
|||
app()->setLocale($locale);
|
||||
Mail::queue($notification);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
namespace Webkul\Core\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class Install extends Command
|
||||
{
|
||||
|
|
@ -33,20 +33,15 @@ class Install extends Command
|
|||
}
|
||||
|
||||
/**
|
||||
* Install and configure bagisto
|
||||
* Install and configure bagisto.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// check for .env
|
||||
$this->checkForEnvFile();
|
||||
|
||||
// cached new changes
|
||||
$this->warn('Step: Caching new changes...');
|
||||
$cached = $this->call('config:cache');
|
||||
$this->info($cached);
|
||||
|
||||
// waiting for 2 seconds
|
||||
$this->warn('Please wait...');
|
||||
sleep(2);
|
||||
// loading values at runtime
|
||||
$this->loadEnvConfigAtRuntime();
|
||||
|
||||
// running `php artisan migrate`
|
||||
$this->warn('Step: Migrating all tables into database...');
|
||||
|
|
@ -54,25 +49,31 @@ class Install extends Command
|
|||
$this->info($migrate);
|
||||
|
||||
// running `php artisan db:seed`
|
||||
$this->warn('Step: seeding basic data for bagisto kickstart...');
|
||||
$this->warn('Step: Seeding basic data for Bagisto kickstart...');
|
||||
$result = $this->call('db:seed');
|
||||
$this->info($result);
|
||||
|
||||
// running `php artisan vendor:publish --all`
|
||||
$this->warn('Step: Publishing Assets and Configurations...');
|
||||
$this->warn('Step: Publishing assets and configurations...');
|
||||
$result = $this->call('vendor:publish', ['--all']);
|
||||
$this->info($result);
|
||||
|
||||
// running `php artisan storage:link`
|
||||
$this->warn('Step: Linking Storage directory...');
|
||||
$this->warn('Step: Linking storage directory...');
|
||||
$result = $this->call('storage:link');
|
||||
$this->info($result);
|
||||
|
||||
// optimizing stuffs
|
||||
$this->warn('Step: Optimizing...');
|
||||
$result = $this->call('optimize');
|
||||
$this->info($result);
|
||||
|
||||
// running `composer dump-autoload`
|
||||
$this->warn('Step: Composer Autoload...');
|
||||
$this->warn('Step: Composer autoload...');
|
||||
$result = shell_exec('composer dump-autoload');
|
||||
$this->info($result);
|
||||
|
||||
// final information
|
||||
$this->info('-----------------------------');
|
||||
$this->info('Congratulations!');
|
||||
$this->info('The installation has been finished and you can now use Bagisto.');
|
||||
|
|
@ -85,28 +86,30 @@ class Install extends Command
|
|||
/**
|
||||
* Checking .env file and if not found then create .env file.
|
||||
* Then ask for database name, password & username to set
|
||||
* On .env file so that we can easily migrate to our db
|
||||
* On .env file so that we can easily migrate to our db.
|
||||
*/
|
||||
public function checkForEnvFile()
|
||||
protected function checkForEnvFile()
|
||||
{
|
||||
$envExists = File::exists(base_path() . '/.env');
|
||||
|
||||
if (! $envExists) {
|
||||
$this->info('Creating the environment configuration file.');
|
||||
$this->createEnvFile();
|
||||
} else {
|
||||
$this->call('key:generate');
|
||||
$this->info('Great! your environment configuration file already exists.');
|
||||
}
|
||||
|
||||
$this->call('key:generate');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new .env file.
|
||||
*/
|
||||
public function createEnvFile()
|
||||
protected function createEnvFile()
|
||||
{
|
||||
try {
|
||||
File::copy('.env.example', '.env');
|
||||
Artisan::call('key:generate');
|
||||
|
||||
$default_app_url = 'http://localhost:8000';
|
||||
$input_app_url = $this->ask('Please Enter the APP URL : ');
|
||||
$this->envUpdate('APP_URL=', $input_app_url ? $input_app_url : $default_app_url );
|
||||
|
|
@ -125,7 +128,6 @@ class Install extends Command
|
|||
$currency = $this->choice('Please 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 it manually and then run `php artisan migrate` again.');
|
||||
|
|
@ -135,21 +137,65 @@ class Install extends Command
|
|||
/**
|
||||
* Add the database credentials to the .env file.
|
||||
*/
|
||||
public function addDatabaseDetails()
|
||||
protected 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?');
|
||||
|
||||
$this->envUpdate('DB_DATABASE=', $dbName);
|
||||
|
||||
$dbUser = $this->anticipate('What is your database username?', ['root']);
|
||||
$this->envUpdate('DB_USERNAME=', $dbUser);
|
||||
|
||||
$dbPass = $this->secret('What is your database password?');
|
||||
$this->envUpdate('DB_PASSWORD=', $dbPass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load `.env` config at runtime.
|
||||
*/
|
||||
protected function loadEnvConfigAtRuntime()
|
||||
{
|
||||
$this->warn('Loading configs...');
|
||||
|
||||
/* environment directly checked from `.env` so changing in config won't reflect */
|
||||
app()['env'] = $this->getEnvAtRuntime('APP_ENV');
|
||||
|
||||
/* setting for the first time and then `.env` values will be incharged */
|
||||
config(['database.connections.mysql.database' => $this->getEnvAtRuntime('DB_DATABASE')]);
|
||||
config(['database.connections.mysql.username' => $this->getEnvAtRuntime('DB_USERNAME')]);
|
||||
config(['database.connections.mysql.password' => $this->getEnvAtRuntime('DB_PASSWORD')]);
|
||||
DB::purge('mysql');
|
||||
|
||||
$this->info('Configuration loaded..');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check key in `.env` file because it will help to find values at runtime.
|
||||
*/
|
||||
protected static function getEnvAtRuntime($key)
|
||||
{
|
||||
$path = base_path() . '/.env';
|
||||
$data = file($path);
|
||||
|
||||
if ($data) {
|
||||
foreach ($data as $line) {
|
||||
$line = preg_replace('/\s+/', '', $line);
|
||||
$rowValues = explode('=', $line);
|
||||
|
||||
if (strlen($line) !== 0) {
|
||||
if (strpos($key, $rowValues[0]) !== false) {
|
||||
return $rowValues[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the .env values.
|
||||
*/
|
||||
public static function envUpdate($key, $value)
|
||||
protected static function envUpdate($key, $value)
|
||||
{
|
||||
$path = base_path() . '/.env';
|
||||
$data = file($path);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
$phpbin = PHP_BINDIR . '/php';
|
||||
|
||||
// array to hold validation errors
|
||||
$errors = array();
|
||||
$errors = array();
|
||||
|
||||
// array to pass back data
|
||||
$data = array();
|
||||
$data = array();
|
||||
|
||||
// validate the variables
|
||||
// if any of these variables don't exist, add an error to our $errors array
|
||||
|
|
@ -101,7 +103,7 @@ $data = array();
|
|||
$data['support_error'] = 'Bagisto currently support MySQL only. Press OK to still continue or change you DB connection to MySQL';
|
||||
}
|
||||
|
||||
$storage_output = exec('cd ../.. && php artisan storage:link 2>&1');
|
||||
$storage_output = exec('cd ../.. && '. $phpbin .' artisan storage:link 2>&1');
|
||||
|
||||
// if there are no errors process our form, then return a message
|
||||
// show a message of success and provide a true success variable
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ $data = array();
|
|||
|
||||
if (empty($_POST['app_url']))
|
||||
$errors['app_url'] = 'App Url is required.';
|
||||
|
||||
if (empty($_POST['app_admin_url']))
|
||||
$errors['app_admin'] = 'The admin suffix is required.';
|
||||
|
||||
if (empty($_POST['app_currency']))
|
||||
$errors['app_currency'] = 'The application currency is required.';
|
||||
|
|
@ -38,6 +41,9 @@ $data = array();
|
|||
|
||||
if (preg_match('/\s/', $_POST['app_url']))
|
||||
$errors['app_url_space'] = 'There should be no space in App URL ';
|
||||
|
||||
if (preg_match('/\s/', $_POST['app_admin_url']))
|
||||
$errors['app_admin_space'] = 'There should be no space in the admin suffix.';
|
||||
|
||||
if (preg_match('/\s/', $_POST['app_name']))
|
||||
$errors['app_name_space'] = 'There should be no space in App Name.';
|
||||
|
|
@ -110,6 +116,7 @@ $data = array();
|
|||
$keyValueData['DB_PASSWORD'] = $_POST["user_password"];
|
||||
$keyValueData['APP_NAME'] = $_POST["app_name"];
|
||||
$keyValueData['APP_URL'] = $_POST["app_url"];
|
||||
$keyValueData['APP_ADMIN_URL'] = $_POST["app_admin_url"];
|
||||
$keyValueData['APP_CURRENCY'] = $_POST["app_currency"];
|
||||
$keyValueData['APP_LOCALE'] = $_POST["app_locale"];
|
||||
$keyValueData['APP_TIMEZONE'] = $_POST["app_timezone"];
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
<?php
|
||||
|
||||
ini_set('max_execution_time', 300);
|
||||
$phpbin = PHP_BINDIR . '/php';
|
||||
|
||||
// array to pass back data
|
||||
$data = [];
|
||||
|
||||
// run command on terminal and asumming that this is as fresh installation
|
||||
$command = 'cd ../.. && php artisan config:cache && php artisan migrate:fresh --force';
|
||||
$command = 'cd ../.. && '. $phpbin .' artisan config:cache && '. $phpbin.' artisan migrate:fresh --force';
|
||||
$data['last_line'] = exec($command, $data['migrate'], $data['results']);
|
||||
|
||||
// return a response
|
||||
|
|
|
|||
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
// array to pass back data
|
||||
$data = array();
|
||||
$phpbin = PHP_BINDIR . '/php';
|
||||
|
||||
// run command on terminal
|
||||
$key = 'cd ../.. && php artisan key:generate 2>&1';
|
||||
$seeder = 'cd ../.. && php artisan db:seed 2>&1';
|
||||
$publish = 'cd ../.. && php artisan vendor:publish --all --force 2>&1';
|
||||
$key = 'cd ../.. && '. $phpbin .' artisan key:generate 2>&1';
|
||||
$seeder = 'cd ../.. && '. $phpbin .' artisan db:seed 2>&1';
|
||||
$publish = 'cd ../.. && '. $phpbin .' artisan vendor:publish --all --force 2>&1';
|
||||
|
||||
$key_output = exec($key, $data['key'], $data['key_results']);
|
||||
$seeder_output = exec($seeder, $data['seeder'], $data['seeder_results']);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,12 @@
|
|||
<div class="form-group" id="app_url">
|
||||
<label for="application_url" class="required">Default URL</label>
|
||||
<input type="text" name="app_url" id="application_url" class="form-control" value="https://<?php echo $_SERVER['HTTP_HOST']; ?>"
|
||||
data-validation="required length" data-validation-length="max50">
|
||||
data-validation="required">
|
||||
</div>
|
||||
|
||||
<div class="form-group" id="app_url">
|
||||
<label for="application_admin" class="required">Default admin suffix</label>
|
||||
<input type="text" name="app_admin_url" id="application_admin" class="form-control" value="admin" data-validation="required">
|
||||
</div>
|
||||
|
||||
<div class="form-group" id="app_currency">
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@
|
|||
|
||||
<div class="container migration" id="migration">
|
||||
<div class="initial-display">
|
||||
<p>Database Configuration</p>
|
||||
<p>Ready for installation</p>
|
||||
</div>
|
||||
|
||||
<div class="row justify-content-center">
|
||||
|
|
@ -68,33 +68,32 @@
|
|||
|
||||
<div class="instructions" style="padding-top: 40px;" id="instructions">
|
||||
<div style="text-align: center;">
|
||||
<h4> Click the button below to run following :</h4>
|
||||
<h4>Click the button below to:</h4>
|
||||
</div>
|
||||
|
||||
<div class="message">
|
||||
<span>Create the database tables </span>
|
||||
<span>Create the database tables</span>
|
||||
</div>
|
||||
|
||||
<div class="message">
|
||||
<span> Populate the database tables </span>
|
||||
<span>Populate the database tables </span>
|
||||
</div>
|
||||
|
||||
<div class="message">
|
||||
<span> Publishing Vendor </span>
|
||||
<span>Publishing the vendor files</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-center">
|
||||
<p class="composer" id="comp">Checking Composer Dependency</p>
|
||||
<p class="composer" id="composer-migrate">Migrating Database</p>
|
||||
<p class="composer" id="composer-seed">Seeding Data</p>
|
||||
<p class="composer" id="comp">Checking Composer dependencies</p>
|
||||
<p class="composer" id="composer-migrate">Creating the database tables, this can take a few moments.</p>
|
||||
<p class="composer" id="composer-seed">Populating the database tables</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="clearfix"> </div>
|
||||
|
||||
|
||||
<form method="POST" id="migration-form">
|
||||
<div style="text-align: center;">
|
||||
<button class="btn btn-primary" id="migrate-seed">Start installation</button>
|
||||
|
|
|
|||
Loading…
Reference in New Issue