connection->transaction(function () use ($database, $password) { $this->dynamic->set('dynamic', $database->database_host_id); $database->update([ 'password' => $this->encrypter->encrypt($password), ]); $database->dropUser($database->username, $database->remote); $database->createUser($database->username, $database->remote, $password, $database->max_connections); $database->assignUserToDatabase($database->database, $database->username, $database->remote); $database->flush(); }); return $password; } }