info('Upgrading your application to version ' . $this->argument('version')); $this->call('down'); // Version 1.7 if ($this->argument('version') === 'v1.7') { $this->version_1_7(); } // Version 1.6 if ($this->argument('version') === 'v1.6') { $this->version_1_6(); } $this->call('up'); $this->info('Your application was upgraded! 🥳🥳🥳'); } /** * Upgrade script to version 1.7 */ public function version_1_7() { // Migrate new tables and changes $this->call('migrate'); $this->call('rinvex:migrate:subscriptions'); /*$this->call('db:seed', [ '--class' => 'PaymentGatewaysSeeder' ]);*/ } /** * Upgrade script to version 1.6 */ public function version_1_6() { // Migrate new tables and changes $this->call('migrate'); // Create user settings records $this->info('Updating users options...'); User::all()->each(function ($user) { $this->info('Update user with id: ' . $user->id); UserSettings::create(['user_id' => $user->id]); }); $this->info('Updating user options is done!'); // Set up admin $email = $this->ask('Which user would you like set up as admin? Please type user email'); $admin = User::where('email', $email)->first(); if (! $admin) { $email = $this->ask('We can\'t find user with this email, please try it again'); $admin = User::where('email', $email)->first(); } // Save new role for selected user $admin->role = 'admin'; $admin->save(); $this->info('Admin was set up successfully'); } }