Update subuser API output to work correctly

This commit is contained in:
Dane Everitt 2019-12-28 11:39:44 -08:00
parent 34bf452bef
commit 66ead2f682
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
3 changed files with 9 additions and 4 deletions

View File

@ -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

View File

@ -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');
} }
/** /**

View File

@ -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),
]; ];