get(); if ($hosts->isEmpty()) { throw new NoSuitableDatabaseHostException(); } $nodeHosts = $server->node->databaseHosts()->get(); // TODO: @areyouscared remove allow random feature for database hosts if ($nodeHosts->isEmpty() && !config('panel.client_features.databases.allow_random')) { throw new NoSuitableDatabaseHostException(); } return $this->managementService->create($server, [ 'database_host_id' => $nodeHosts->isEmpty() ? $hosts->random()->id : $nodeHosts->random()->id, 'database' => DatabaseManagementService::generateUniqueDatabaseName($data['database'], $server->id), 'remote' => $data['remote'], ]); } }