Update subuser API output to work correctly
This commit is contained in:
parent
34bf452bef
commit
66ead2f682
|
@ -13,7 +13,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
* The application API now includes the egg's name in the egg model's response.
|
* The application API now includes the egg's name in the egg model's response.
|
||||||
* The /api/application/servers endpoint can now include server's databases and subusers
|
* The /api/application/servers endpoint can now include server's databases and subusers.
|
||||||
|
|
||||||
## v0.7.15 (Derelict Dermodactylus)
|
## v0.7.15 (Derelict Dermodactylus)
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -168,11 +168,11 @@ class Server extends Model implements CleansAttributes, ValidableContract
|
||||||
/**
|
/**
|
||||||
* Gets the subusers associated with a server.
|
* Gets the subusers associated with a server.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||||
*/
|
*/
|
||||||
public function subusers()
|
public function subusers()
|
||||||
{
|
{
|
||||||
return $this->hasManyThrough(User::class, Subuser::class, 'server_id', 'id', 'id', 'user_id');
|
return $this->hasMany(Subuser::class, 'server_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace Pterodactyl\Transformers\Api\Application;
|
namespace Pterodactyl\Transformers\Api\Application;
|
||||||
|
|
||||||
use Pterodactyl\Models\Subuser;
|
use Pterodactyl\Models\Subuser;
|
||||||
|
use Pterodactyl\Models\Permission;
|
||||||
use Pterodactyl\Services\Acl\Api\AdminAcl;
|
use Pterodactyl\Services\Acl\Api\AdminAcl;
|
||||||
|
|
||||||
class SubuserTransformer extends BaseTransformer
|
class SubuserTransformer extends BaseTransformer
|
||||||
|
@ -34,7 +35,11 @@ class SubuserTransformer extends BaseTransformer
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => $subuser->id,
|
'id' => $subuser->id,
|
||||||
'permissions' => $subuser->permissions->toArray(),
|
'user_id' => $subuser->user_id,
|
||||||
|
'server_id' => $subuser->server_id,
|
||||||
|
'permissions' => $subuser->permissions->map(function (Permission $permission) {
|
||||||
|
return $permission->permission;
|
||||||
|
}),
|
||||||
'created_at' => $this->formatTimestamp($subuser->created_at),
|
'created_at' => $this->formatTimestamp($subuser->created_at),
|
||||||
'updated_at' => $this->formatTimestamp($subuser->updated_at),
|
'updated_at' => $this->formatTimestamp($subuser->updated_at),
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue