Add more CLI commands for panel management

This commit is contained in:
Dane Everitt 2017-09-19 22:10:14 -05:00
parent 763f7a996a
commit ccda2b63fa
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
15 changed files with 496 additions and 516 deletions

View file

@ -47,13 +47,30 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
*/
public function getAllServers($paginate = 25)
{
$instance = $this->getBuilder()->with('node', 'user', 'allocation');
Assert::nullOrIntegerish($paginate, 'First argument passed to getAllServers must be integer or null, received %s.');
if ($this->searchTerm) {
$instance->search($this->searchTerm);
$instance = $this->getBuilder()->with('node', 'user', 'allocation')->search($this->searchTerm);
return is_null($paginate) ? $instance->get($this->getColumns()) : $instance->paginate($paginate, $this->getColumns());
}
/**
* {@inheritdoc}
*/
public function getDataForRebuild($server = null, $node = null)
{
Assert::nullOrIntegerish($server, 'First argument passed to getDataForRebuild must be null or integer, received %s.');
Assert::nullOrIntegerish($node, 'Second argument passed to getDataForRebuild must be null or integer, received %s.');
$instance = $this->getBuilder()->with('node', 'option.service', 'pack');
if (! is_null($server) && is_null($node)) {
$instance = $instance->where('id', '=', $server);
} elseif (is_null($server) && ! is_null($node)) {
$instance = $instance->where('node_id', '=', $node);
}
return $instance->paginate($paginate);
return $instance->get($this->getColumns());
}
/**
@ -62,6 +79,8 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
*/
public function findWithVariables($id)
{
Assert::integerish($id, 'First argument passed to findWithVariables must be integer, received %s.');
$instance = $this->getBuilder()->with('option.variables', 'variables')
->where($this->getModel()->getKeyName(), '=', $id)
->first($this->getColumns());