fixed install/update locale
This commit is contained in:
parent
f7b0ef8973
commit
a92689d3e3
@ -3,6 +3,7 @@
|
|||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Events\Install\UpdateFinished;
|
use App\Events\Install\UpdateFinished;
|
||||||
|
use App\Models\Common\Company;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
class FinishUpdate extends Command
|
class FinishUpdate extends Command
|
||||||
@ -12,7 +13,7 @@ class FinishUpdate extends Command
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'update:finish {alias} {company_id} {new} {old}';
|
protected $signature = 'update:finish {alias} {company} {new} {old}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
@ -43,7 +44,7 @@ class FinishUpdate extends Command
|
|||||||
$this->call('cache:clear');
|
$this->call('cache:clear');
|
||||||
|
|
||||||
$alias = $this->argument('alias');
|
$alias = $this->argument('alias');
|
||||||
$company_id = $this->argument('company_id');
|
$company_id = $this->argument('company');
|
||||||
$new = $this->argument('new');
|
$new = $this->argument('new');
|
||||||
$old = $this->argument('old');
|
$old = $this->argument('old');
|
||||||
|
|
||||||
@ -53,6 +54,11 @@ class FinishUpdate extends Command
|
|||||||
throw new \Exception(trans('modules.errors.finish', ['module' => $alias]));
|
throw new \Exception(trans('modules.errors.finish', ['module' => $alias]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set locale for modules
|
||||||
|
if ($alias != 'core') {
|
||||||
|
app()->setLocale(Company::find($company_id)->locale);
|
||||||
|
}
|
||||||
|
|
||||||
session(['company_id' => $company_id]);
|
session(['company_id' => $company_id]);
|
||||||
setting()->setExtraColumns(['company_id' => $company_id]);
|
setting()->setExtraColumns(['company_id' => $company_id]);
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@ class Install extends Command
|
|||||||
|
|
||||||
$this->line('Setting locale ' . $this->locale);
|
$this->line('Setting locale ' . $this->locale);
|
||||||
Session::put(self::OPT_LOCALE, $this->locale);
|
Session::put(self::OPT_LOCALE, $this->locale);
|
||||||
|
app()->setLocale($this->locale);
|
||||||
|
|
||||||
$this->prompt();
|
$this->prompt();
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ class Update extends Command
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'update {alias} {company_id} {new=latest}';
|
protected $signature = 'update {alias} {company} {new=latest}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
@ -55,8 +55,8 @@ class Update extends Command
|
|||||||
|
|
||||||
$this->old = $this->getOldVersion();
|
$this->old = $this->getOldVersion();
|
||||||
|
|
||||||
session(['company_id' => $this->argument('company_id')]);
|
session(['company_id' => $this->argument('company')]);
|
||||||
setting()->setExtraColumns(['company_id' => $this->argument('company_id')]);
|
setting()->setExtraColumns(['company_id' => $this->argument('company')]);
|
||||||
|
|
||||||
if (!$path = $this->download()) {
|
if (!$path = $this->download()) {
|
||||||
return self::CMD_ERROR;
|
return self::CMD_ERROR;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Install;
|
namespace App\Http\Controllers\Install;
|
||||||
|
|
||||||
use Session;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Routing\Controller;
|
use Illuminate\Routing\Controller;
|
||||||
|
|
||||||
@ -28,7 +27,8 @@ class Language extends Controller
|
|||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
// Set locale
|
// Set locale
|
||||||
Session::put('locale', $request['lang']);
|
session(['locale' => $request->get('lang')]);
|
||||||
|
app()->setLocale($request->get('lang'));
|
||||||
|
|
||||||
$response['redirect'] = route('install.database');
|
$response['redirect'] = route('install.database');
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ class Language extends Controller
|
|||||||
public function getLanguages()
|
public function getLanguages()
|
||||||
{
|
{
|
||||||
$response = [
|
$response = [
|
||||||
'languages' => $languages = language()->allowed(),
|
'languages' => language()->allowed(),
|
||||||
];
|
];
|
||||||
|
|
||||||
return response()->json($response);
|
return response()->json($response);
|
||||||
|
@ -81,6 +81,8 @@ class Version200 extends Listener
|
|||||||
$companies = Company::cursor();
|
$companies = Company::cursor();
|
||||||
|
|
||||||
foreach ($companies as $company) {
|
foreach ($companies as $company) {
|
||||||
|
session(['company_id' => $company->id]);
|
||||||
|
|
||||||
$this->updateSettings($company);
|
$this->updateSettings($company);
|
||||||
|
|
||||||
$this->createEmailTemplates($company);
|
$this->createEmailTemplates($company);
|
||||||
@ -97,12 +99,16 @@ class Version200 extends Listener
|
|||||||
|
|
||||||
public function updateSettings($company)
|
public function updateSettings($company)
|
||||||
{
|
{
|
||||||
// Clear current settings
|
// Set the active company settings
|
||||||
|
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||||
setting()->forgetAll();
|
setting()->forgetAll();
|
||||||
|
setting()->load(true);
|
||||||
|
|
||||||
session(['company_id' => $company->id]);
|
// Override settings
|
||||||
|
config(['app.url' => url('/')]);
|
||||||
Overrider::load('settings');
|
config(['app.timezone' => setting('general.timezone', 'UTC')]);
|
||||||
|
date_default_timezone_set(config('app.timezone'));
|
||||||
|
app()->setLocale(setting('general.default_locale'));
|
||||||
|
|
||||||
$updated_settings = [
|
$updated_settings = [
|
||||||
'company.name' => 'general.company_name',
|
'company.name' => 'general.company_name',
|
||||||
@ -325,6 +331,8 @@ class Version200 extends Listener
|
|||||||
$companies = $user->companies;
|
$companies = $user->companies;
|
||||||
|
|
||||||
foreach ($companies as $company) {
|
foreach ($companies as $company) {
|
||||||
|
app()->setLocale($company->locale);
|
||||||
|
|
||||||
Artisan::call('user:seed', [
|
Artisan::call('user:seed', [
|
||||||
'user' => $user->id,
|
'user' => $user->id,
|
||||||
'company' => $company->id,
|
'company' => $company->id,
|
||||||
|
@ -407,12 +407,13 @@ trait Modules
|
|||||||
$data = [
|
$data = [
|
||||||
'path' => $path,
|
'path' => $path,
|
||||||
'name' => Str::studly($module->alias),
|
'name' => Str::studly($module->alias),
|
||||||
'alias' => $module->alias
|
'alias' => $module->alias,
|
||||||
];
|
];
|
||||||
|
|
||||||
$company_id = session('company_id');
|
$company_id = session('company_id');
|
||||||
|
$locale = app()->getLocale();
|
||||||
|
|
||||||
Console::run("php artisan module:install {$module->alias} {$company_id}");
|
Console::run("php artisan module:install {$module->alias} {$company_id} {$locale}");
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'success' => true,
|
'success' => true,
|
||||||
|
@ -51,9 +51,7 @@ class Overrider
|
|||||||
|
|
||||||
// Locale
|
// Locale
|
||||||
if (session('locale') == '') {
|
if (session('locale') == '') {
|
||||||
//App::setLocale(setting('default.locale'));
|
app()->setLocale(setting('default.locale'));
|
||||||
//Session::put('locale', setting('default.locale'));
|
|
||||||
config(['app.locale' => setting('default.locale')]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set app url dynamically
|
// Set app url dynamically
|
||||||
|
@ -5,6 +5,7 @@ namespace App\Utilities;
|
|||||||
use App\Events\Install\UpdateCopied;
|
use App\Events\Install\UpdateCopied;
|
||||||
use App\Events\Install\UpdateDownloaded;
|
use App\Events\Install\UpdateDownloaded;
|
||||||
use App\Events\Install\UpdateUnzipped;
|
use App\Events\Install\UpdateUnzipped;
|
||||||
|
use App\Models\Module\Module;
|
||||||
use App\Utilities\Console;
|
use App\Utilities\Console;
|
||||||
use App\Traits\SiteApi;
|
use App\Traits\SiteApi;
|
||||||
use Artisan;
|
use Artisan;
|
||||||
@ -125,14 +126,20 @@ class Updater
|
|||||||
|
|
||||||
public static function finish($alias, $new, $old)
|
public static function finish($alias, $new, $old)
|
||||||
{
|
{
|
||||||
$company_id = session('company_id');
|
if ($alias == 'core') {
|
||||||
|
$companies = [session('company_id')];
|
||||||
|
} else {
|
||||||
|
$companies = Module::alias($alias)->where('company_id', '<>', '0')->pluck('company_id')->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
$command = "php artisan update:finish {$alias} {$company_id} {$new} {$old}";
|
foreach ($companies as $company) {
|
||||||
|
$command = "php artisan update:finish {$alias} {$company} {$new} {$old}";
|
||||||
|
|
||||||
if (true !== $result = Console::run($command)) {
|
if (true !== $result = Console::run($command)) {
|
||||||
$message = !empty($result) ? $result : trans('modules.errors.finish', ['module' => $alias]);
|
$message = !empty($result) ? $result : trans('modules.errors.finish', ['module' => $alias]);
|
||||||
|
|
||||||
throw new \Exception($message);
|
throw new \Exception($message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,16 @@ class Modules extends Seeder
|
|||||||
{
|
{
|
||||||
$company_id = $this->command->argument('company');
|
$company_id = $this->command->argument('company');
|
||||||
|
|
||||||
Artisan::call('module:install', ['alias' => 'offline-payments', 'company_id' => $company_id]);
|
Artisan::call('module:install', [
|
||||||
Artisan::call('module:install', ['alias' => 'paypal-standard', 'company_id' => $company_id]);
|
'alias' => 'offline-payments',
|
||||||
|
'company' => $company_id,
|
||||||
|
'locale' => session('locale', app()->getLocale()),
|
||||||
|
]);
|
||||||
|
|
||||||
|
Artisan::call('module:install', [
|
||||||
|
'alias' => 'paypal-standard',
|
||||||
|
'company' => $company_id,
|
||||||
|
'locale' => session('locale', app()->getLocale()),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ class InstallCommand extends Command
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'module:install {alias} {company_id}';
|
protected $signature = 'module:install {alias} {company} {locale=en-GB}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
@ -36,12 +36,15 @@ class InstallCommand extends Command
|
|||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$alias = Str::kebab($this->argument('alias'));
|
$alias = Str::kebab($this->argument('alias'));
|
||||||
$company_id = $this->argument('company_id');
|
$company_id = $this->argument('company');
|
||||||
|
$locale = $this->argument('locale');
|
||||||
|
|
||||||
$old_company_id = session('company_id');
|
$old_company_id = session('company_id');
|
||||||
|
|
||||||
session(['company_id' => $company_id]);
|
session(['company_id' => $company_id]);
|
||||||
|
|
||||||
|
app()->setLocale($locale);
|
||||||
|
|
||||||
$module = module($alias);
|
$module = module($alias);
|
||||||
|
|
||||||
$model = Module::create([
|
$model = Module::create([
|
||||||
|
Loading…
x
Reference in New Issue
Block a user