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