[Breaking] Return server allocations automatically as a relation object

This commit is contained in:
Dane Everitt 2020-07-09 19:17:24 -07:00
parent 5c18fd1f0c
commit bfb28f949d
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
3 changed files with 26 additions and 13 deletions

View file

@ -24,13 +24,11 @@ class AllocationTransformer extends BaseClientTransformer
*/
public function transform(Allocation $model)
{
$model->loadMissing('server');
return [
'ip' => $model->ip,
'alias' => $model->ip_alias,
'ip_alias' => $model->ip_alias,
'port' => $model->port,
'default' => $model->getRelation('server')->allocation_id === $model->id,
'is_default' => $model->server->allocation_id === $model->id,
];
}
}