Skip to content

Commit d8e3e0a

Browse files
committed
Merge branch 'develop' into pr/2454
2 parents 1e3f3fb + 8697185 commit d8e3e0a

File tree

85 files changed

+2343
-3038
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+2343
-3038
lines changed

app/Contracts/Repository/DatabaseRepositoryInterface.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,6 @@ public function getDatabasesForServer(int $server): Collection;
4242
*/
4343
public function getDatabasesForHost(int $host, int $count = 25): LengthAwarePaginator;
4444

45-
/**
46-
* Create a new database if it does not already exist on the host with
47-
* the provided details.
48-
*
49-
* @param array $data
50-
* @return \Pterodactyl\Models\Database
51-
*
52-
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
53-
* @throws \Pterodactyl\Exceptions\Repository\DuplicateDatabaseNameException
54-
*/
55-
public function createIfNotExists(array $data): Database;
56-
5745
/**
5846
* Create a new database on a given connection.
5947
*

app/Contracts/Repository/NodeRepositoryInterface.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,4 @@ public function loadNodeAllocations(Node $node, bool $refresh = false): Node;
5454
* @return \Illuminate\Support\Collection
5555
*/
5656
public function getNodesForServerCreation(): Collection;
57-
58-
/**
59-
* Return the IDs of all nodes that exist in the provided locations and have the space
60-
* available to support the additional disk and memory provided.
61-
*
62-
* @param array $locations
63-
* @param int $disk
64-
* @param int $memory
65-
* @return \Illuminate\Support\LazyCollection
66-
*/
67-
public function getNodesWithResourceUse(array $locations, int $disk, int $memory): LazyCollection;
6857
}

app/Http/Controllers/Admin/MountController.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,11 @@ public function view($id)
102102
public function create(MountFormRequest $request)
103103
{
104104
/** @var \Pterodactyl\Models\Mount $mount */
105-
$mount = Mount::query()->create(array_merge($request->validated(), [
106-
'uuid' => Uuid::uuid4()->toString(),
107-
]));
105+
$model = (new Mount())->fill($request->validated());
106+
$model->forceFill(['uuid' => Uuid::uuid4()->toString()]);
107+
108+
$model->saveOrFail();
109+
$mount = $model->fresh();
108110

109111
$this->alert->success('Mount was created successfully.')->flash();
110112

app/Http/Controllers/Admin/Nests/EggScriptController.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Http\Controllers\Admin\Nests;
114

125
use Illuminate\View\View;
6+
use Pterodactyl\Models\Egg;
137
use Illuminate\Http\RedirectResponse;
148
use Prologue\Alerts\AlertsMessageBag;
159
use Pterodactyl\Http\Controllers\Controller;
@@ -81,14 +75,14 @@ public function index(int $egg): View
8175
* Handle a request to update the installation script for an Egg.
8276
*
8377
* @param \Pterodactyl\Http\Requests\Admin\Egg\EggScriptFormRequest $request
84-
* @param int $egg
78+
* @param \Pterodactyl\Models\Egg $egg
8579
* @return \Illuminate\Http\RedirectResponse
8680
*
8781
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
8882
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
8983
* @throws \Pterodactyl\Exceptions\Service\Egg\InvalidCopyFromException
9084
*/
91-
public function update(EggScriptFormRequest $request, int $egg): RedirectResponse
85+
public function update(EggScriptFormRequest $request, Egg $egg): RedirectResponse
9286
{
9387
$this->installScriptService->handle($egg, $request->normalize());
9488
$this->alert->success(trans('admin/nests.eggs.notices.script_updated'))->flash();

app/Http/Controllers/Admin/Nests/EggShareController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ public function import(EggImportFormRequest $request): RedirectResponse
102102
* Update an existing Egg using a new imported file.
103103
*
104104
* @param \Pterodactyl\Http\Requests\Admin\Egg\EggImportFormRequest $request
105-
* @param int $egg
105+
* @param \Pterodactyl\Models\Egg $egg
106106
* @return \Illuminate\Http\RedirectResponse
107107
*
108108
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
109109
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
110110
* @throws \Pterodactyl\Exceptions\Service\Egg\BadJsonFormatException
111111
* @throws \Pterodactyl\Exceptions\Service\InvalidFileUploadException
112112
*/
113-
public function update(EggImportFormRequest $request, int $egg): RedirectResponse
113+
public function update(EggImportFormRequest $request, Egg $egg): RedirectResponse
114114
{
115115
$this->updateImporterService->handle($egg, $request->file('import_file'));
116116
$this->alert->success(trans('admin/nests.eggs.notices.updated_via_import'))->flash();

app/Http/Controllers/Admin/ServersController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public function toggleInstall(Server $server)
252252
*/
253253
public function reinstallServer(Server $server)
254254
{
255-
$this->reinstallService->reinstall($server);
255+
$this->reinstallService->handle($server);
256256
$this->alert->success(trans('admin/server.alerts.server_reinstalled'))->flash();
257257

258258
return redirect()->route('admin.servers.view.manage', $server->id);
@@ -362,7 +362,7 @@ public function saveStartup(Request $request, Server $server)
362362
public function newDatabase(StoreServerDatabaseRequest $request, Server $server)
363363
{
364364
$this->databaseManagementService->create($server, [
365-
'database' => $request->input('database'),
365+
'database' => DatabaseManagementService::generateUniqueDatabaseName($request->input('database'), $server->id),
366366
'remote' => $request->input('remote'),
367367
'database_host_id' => $request->input('database_host_id'),
368368
'max_connections' => $request->input('max_connections'),
@@ -409,7 +409,7 @@ public function deleteDatabase($server, $database)
409409
['id', '=', $database],
410410
]);
411411

412-
$this->databaseManagementService->delete($database->id);
412+
$this->databaseManagementService->delete($database);
413413

414414
return response('', 204);
415415
}

app/Http/Controllers/Admin/UserController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ public function index(Request $request)
8686
{
8787
$users = QueryBuilder::for(
8888
User::query()->select('users.*')
89-
->selectRaw('COUNT(subusers.id) as subuser_of_count')
90-
->selectRaw('COUNT(servers.id) as servers_count')
89+
->selectRaw('COUNT(DISTINCT(subusers.id)) as subuser_of_count')
90+
->selectRaw('COUNT(DISTINCT(servers.id)) as servers_count')
9191
->leftJoin('subusers', 'subusers.user_id', '=', 'users.id')
9292
->leftJoin('servers', 'servers.owner_id', '=', 'users.id')
9393
->groupBy('users.id')

app/Http/Controllers/Api/Application/Servers/DatabaseController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ public function resetPassword(ServerDatabaseWriteRequest $request, Server $serve
110110
*/
111111
public function store(StoreServerDatabaseRequest $request, Server $server): JsonResponse
112112
{
113-
$database = $this->databaseManagementService->create($server, $request->validated());
113+
$database = $this->databaseManagementService->create($server, array_merge($request->validated(), [
114+
'database' => $request->databaseName(),
115+
]));
114116

115117
return $this->fractal->item($database)
116118
->transformWith($this->getTransformer(ServerDatabaseTransformer::class))
@@ -133,7 +135,7 @@ public function store(StoreServerDatabaseRequest $request, Server $server): Json
133135
*/
134136
public function delete(ServerDatabaseWriteRequest $request): Response
135137
{
136-
$this->databaseManagementService->delete($request->getModel(Database::class)->id);
138+
$this->databaseManagementService->delete($request->getModel(Database::class));
137139

138140
return response('', 204);
139141
}

app/Http/Controllers/Api/Application/Servers/ServerManagementController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function unsuspend(ServerWriteRequest $request, Server $server): Response
8282
*/
8383
public function reinstall(ServerWriteRequest $request, Server $server): Response
8484
{
85-
$this->reinstallServerService->reinstall($server);
85+
$this->reinstallServerService->handle($server);
8686

8787
return $this->returnNoContent();
8888
}

app/Http/Controllers/Api/Client/Servers/DatabaseController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function rotatePassword(RotatePasswordRequest $request, Server $server, D
129129
*/
130130
public function delete(DeleteDatabaseRequest $request, Server $server, Database $database): Response
131131
{
132-
$this->managementService->delete($database->id);
132+
$this->managementService->delete($database);
133133

134134
return Response::create('', Response::HTTP_NO_CONTENT);
135135
}

0 commit comments

Comments
 (0)