Skip to content

Commit be91913

Browse files
committed
Return a null resource if an allocation has no server; closes pterodactyl#2117
1 parent b30d742 commit be91913

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

app/Transformers/Api/Application/AllocationTransformer.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Pterodactyl\Transformers\Api\Application;
44

5+
use Pterodactyl\Models\Node;
6+
use Pterodactyl\Models\Server;
57
use Pterodactyl\Models\Allocation;
68
use Pterodactyl\Services\Acl\Api\AdminAcl;
79

@@ -54,10 +56,8 @@ public function includeNode(Allocation $allocation)
5456
return $this->null();
5557
}
5658

57-
$allocation->loadMissing('node');
58-
5959
return $this->item(
60-
$allocation->getRelation('node'), $this->makeTransformer(NodeTransformer::class), 'node'
60+
$allocation->node, $this->makeTransformer(NodeTransformer::class), Node::RESOURCE_NAME
6161
);
6262
}
6363

@@ -70,14 +70,12 @@ public function includeNode(Allocation $allocation)
7070
*/
7171
public function includeServer(Allocation $allocation)
7272
{
73-
if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) {
73+
if (! $this->authorize(AdminAcl::RESOURCE_SERVERS) || ! $allocation->server) {
7474
return $this->null();
7575
}
7676

77-
$allocation->loadMissing('server');
78-
7977
return $this->item(
80-
$allocation->getRelation('server'), $this->makeTransformer(ServerTransformer::class), 'server'
78+
$allocation->server, $this->makeTransformer(ServerTransformer::class), Server::RESOURCE_NAME
8179
);
8280
}
8381
}

0 commit comments

Comments
 (0)