API tweaks to return more relevant information on server listing
This commit is contained in:
parent
32c21baab0
commit
7f51e5df62
2 changed files with 54 additions and 1 deletions
|
@ -117,7 +117,10 @@ class ServerController extends BaseController
|
|||
}
|
||||
|
||||
// Requested Daemon Stats
|
||||
$server = $query->first();
|
||||
$server = $query->with(
|
||||
'allocations',
|
||||
'pack'
|
||||
)->first();
|
||||
if ($request->input('daemon') === 'true') {
|
||||
$node = Models\Node::findOrFail($server->node);
|
||||
$client = Models\Node::guzzleRequest($node->id);
|
||||
|
|
|
@ -208,4 +208,54 @@ class Server extends Model
|
|||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all allocations associated with this server.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function allocations()
|
||||
{
|
||||
return $this->hasMany(Allocation::class, 'assigned_to');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets information for the pack associated with this server.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function pack()
|
||||
{
|
||||
return $this->hasOne(ServicePack::class, 'id', 'pack');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets information for the service associated with this server.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function service()
|
||||
{
|
||||
return $this->hasOne(Service::class, 'id', 'service');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets information for the service option associated with this server.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function option()
|
||||
{
|
||||
return $this->hasOne(ServiceOptions::class, 'id', 'option');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets information for the service variables associated with this server.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function variables()
|
||||
{
|
||||
return $this->hasMany(ServerVariables::class);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue