ui(admin): add role select for user management
This commit is contained in:
parent
58f0bbbb9b
commit
25feeaa9f5
16 changed files with 202 additions and 52 deletions
|
@ -12,7 +12,7 @@ class UserTransformer extends BaseTransformer
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = ['servers'];
|
||||
protected $availableIncludes = ['role', 'servers'];
|
||||
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
|
@ -39,12 +39,32 @@ class UserTransformer extends BaseTransformer
|
|||
'root_admin' => (bool) $model->root_admin,
|
||||
'2fa' => (bool) $model->use_totp,
|
||||
'avatar_url' => $model->avatarURL(),
|
||||
'admin_role_id' => $model->admin_role_id,
|
||||
'role_name' => $model->adminRoleName(),
|
||||
'created_at' => $this->formatTimestamp($model->created_at),
|
||||
'updated_at' => $this->formatTimestamp($model->updated_at),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the role associated with this user.
|
||||
*
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeRole(User $user)
|
||||
{
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_ROLES)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
$user->loadMissing('adminRole');
|
||||
|
||||
return $this->item($user->getRelation('adminRole'), $this->makeTransformer(AdminRoleTransformer::class), 'admin_role');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the servers associated with this user.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue