public function handle()
{
$old_db_user = $this->laravel['config']['database.connections.' . $this->laravel['config']['database.default'] . '.username'];
$file = base_path('.env');
if (file_exists($file)) {
file_put_contents($file, str_replace('DB_USERNAME=' . $old_db_user, 'DB_USERNAME=' . $this->argument('databaseuser'), file_get_contents($file)));
if ($this->option('check')) {
$this->info('The database user has been changed ' . 'successfully to: ' . $this->argument('databaseuser'));
$this->laravel['config']['database.connections.' . $this->laravel['config']['database.default'] . '.username'] = $this->argument('databaseuser');
try {
ArtisanExt::checkDb();
return $this->info('Succesfully connected to the database.');
} catch (\PDOException $e) {
return $this->error('Failed to connect to the database.');
}
return $this->error('Failed to connect to the database.');
}
return $this->info('The database user has been changed ' . 'successfully to: ' . $this->argument('databaseuser'));
}
return $this->error('The .env configuration file is missing.');
}