forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserTransformer.php
More file actions
44 lines (37 loc) · 1.07 KB
/
Copy pathUserTransformer.php
File metadata and controls
44 lines (37 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace Pterodactyl\Transformers\Api\Application;
use Pterodactyl\Models\User;
use Pterodactyl\Services\Acl\Api\AdminAcl;
class UserTransformer extends BaseTransformer
{
/**
* List of resources that can be included.
*
* @var array
*/
protected $availableIncludes = ['servers'];
/**
* Return a generic transformed subuser array.
*
* @param \Pterodactyl\Models\User $user
* @return array
*/
public function transform(User $user): array
{
return $user->toArray();
}
/**
* Return the servers associated with this user.
*
* @param \Pterodactyl\Models\User $user
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
*/
public function includeServers(User $user)
{
if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) {
return $this->null();
}
$user->loadMissing('servers');
return $this->collection($user->getRelation('servers'), $this->makeTransformer(ServerTransformer::class), 'server');
}
}