![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/demo.cartinsight.co/app/Console/Commands/ |
<?php namespace App\Console\Commands; use Corals\Settings\Facades\Modules; use Corals\User\Models\User; use Illuminate\Console\Command; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Schema; class WoobiDeployment extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'woobi:install'; /** * The console command description. * * @var string */ protected $description = 'deploy woobi updateOrInstall modules'; /** * Execute the console command. * * @return int */ public function handle() { $this->line('run clear caches command'); Artisan::call('c:c'); $this->line(Artisan::output()); Artisan::call('migrate'); $this->line(Artisan::output()); if (!Schema::hasTable('users')) { $this->line('Start fresh installation'); $freshCommands = ['migrate:fresh', 'db:seed']; foreach ($freshCommands as $command) { $this->line($command); Artisan::call($command); $this->line(Artisan::output()); } } $availableModules = Modules::getModulesSettings(); $this->line('Check and update core modules'); $availableModules->where('type', 'core')->each(function ($module) { Modules::update($module->code); }); $sortedModules = [ 'corals-utility', 'corals-utility-webhook', 'corals-utility-listOfValue', 'corals-report', 'corals-woocommerce', ]; $this->line('Update or install required modules'); foreach ($sortedModules as $moduleCode) { if ($availableModules->where('code', $moduleCode)->where('installed')->isEmpty()) { $this->line(sprintf('%s:: %s', $moduleCode, 'install')); try { Modules::install($moduleCode); } catch (\Exception $exception) { $this->line(sprintf( '%s:: %s because of: %s', $moduleCode, 'retry install', $exception->getMessage() )); Modules::uninstall($moduleCode); //do another try in case of failure Modules::install($moduleCode); } } else { $this->line(sprintf('%s:: %s', $moduleCode, 'update')); Modules::update($moduleCode); } } $superuserData['name'] = $this->ask('Superuser first name:', 'Superuser'); $superuserData['last_name'] = $this->ask('Superuser last name:', 'Admin'); $superuserData['email'] = $this->ask('Superuser email:', '[email protected]'); $superuserData['password'] = $this->secret('Superuser password:'); User::find(1)->update($superuserData); $this->line('run clear caches command'); Artisan::call('c:c'); return 0; } }