deployDatabaseService = $deployDatabaseService; $this->repository = $repository; $this->managementService = $managementService; $this->passwordService = $passwordService; } /** * Return all of the databases that belong to the given server. * * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function index(GetDatabasesRequest $request, Server $server): array { return $this->fractal->collection($server->databases) ->transformWith(DatabaseTransformer::class) ->toArray(); } /** * Create a new database for the given server and return it. * * @throws \Throwable * @throws \Pterodactyl\Exceptions\Service\Database\TooManyDatabasesException * @throws \Pterodactyl\Exceptions\Service\Database\DatabaseClientFeatureNotEnabledException */ public function store(StoreDatabaseRequest $request, Server $server): array { $database = $this->deployDatabaseService->handle($server, $request->validated()); return $this->fractal->item($database) ->parseIncludes(['password']) ->transformWith(DatabaseTransformer::class) ->toArray(); } /** * Rotates the password for the given server model and returns a fresh instance to * the caller. * * @throws \Throwable */ public function rotatePassword(RotatePasswordRequest $request, Server $server, Database $database): array { $this->passwordService->handle($database); $database->refresh(); return $this->fractal->item($database) ->parseIncludes(['password']) ->transformWith(DatabaseTransformer::class) ->toArray(); } /** * Removes a database from the server. * * @throws \Exception */ public function delete(DeleteDatabaseRequest $request, Server $server, Database $database): Response { $this->managementService->delete($database); return $this->returnNoContent(); } }