Fix database column references in ACP

This commit is contained in:
Dane Everitt 2017-02-02 19:46:46 -05:00
parent 3baa21a6eb
commit 533e2bcafb
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 5 additions and 5 deletions

View file

@ -46,7 +46,7 @@ class LocationsController extends Controller
'locations' => Models\Location::select( 'locations' => Models\Location::select(
'locations.*', 'locations.*',
DB::raw('(SELECT COUNT(*) FROM nodes WHERE nodes.location = locations.id) as a_nodeCount'), DB::raw('(SELECT COUNT(*) FROM nodes WHERE nodes.location = locations.id) as a_nodeCount'),
DB::raw('(SELECT COUNT(*) FROM servers WHERE servers.node IN (SELECT nodes.id FROM nodes WHERE nodes.location = locations.id)) as a_serverCount') DB::raw('(SELECT COUNT(*) FROM servers WHERE servers.node_id IN (SELECT nodes.id FROM nodes WHERE nodes.location = locations.id)) as a_serverCount')
)->paginate(20), )->paginate(20),
]); ]);
} }
@ -56,7 +56,7 @@ class LocationsController extends Controller
$model = Models\Location::select( $model = Models\Location::select(
'locations.id', 'locations.id',
DB::raw('(SELECT COUNT(*) FROM nodes WHERE nodes.location = locations.id) as a_nodeCount'), DB::raw('(SELECT COUNT(*) FROM nodes WHERE nodes.location = locations.id) as a_nodeCount'),
DB::raw('(SELECT COUNT(*) FROM servers WHERE servers.node IN (SELECT nodes.id FROM nodes WHERE nodes.location = locations.id)) as a_serverCount') DB::raw('(SELECT COUNT(*) FROM servers WHERE servers.node_id IN (SELECT nodes.id FROM nodes WHERE nodes.location = locations.id)) as a_serverCount')
)->where('id', $id)->first(); )->where('id', $id)->first();
if (! $model) { if (! $model) {

View file

@ -57,7 +57,7 @@ class NodesController extends Controller
'nodes' => Models\Node::select( 'nodes' => Models\Node::select(
'nodes.*', 'nodes.*',
'locations.long as a_locationName', 'locations.long as a_locationName',
DB::raw('(SELECT COUNT(*) FROM servers WHERE servers.node = nodes.id) as a_serverCount') DB::raw('(SELECT COUNT(*) FROM servers WHERE servers.node_id = nodes.id) as a_serverCount')
)->join('locations', 'nodes.location', '=', 'locations.id')->paginate(20), )->join('locations', 'nodes.location', '=', 'locations.id')->paginate(20),
]); ]);
} }
@ -110,8 +110,8 @@ class NodesController extends Controller
'servers' => Models\Server::select('servers.*', 'users.email as a_ownerEmail', 'services.name as a_serviceName') 'servers' => Models\Server::select('servers.*', 'users.email as a_ownerEmail', 'services.name as a_serviceName')
->join('users', 'users.id', '=', 'servers.owner_id') ->join('users', 'users.id', '=', 'servers.owner_id')
->join('services', 'services.id', '=', 'servers.service_id') ->join('services', 'services.id', '=', 'servers.service_id')
->where('node', $id)->paginate(10, ['*'], 'servers'), ->where('node_id', $id)->paginate(10, ['*'], 'servers'),
'stats' => Models\Server::select(DB::raw('SUM(memory) as memory, SUM(disk) as disk'))->where('node', $node->id)->first(), 'stats' => Models\Server::select(DB::raw('SUM(memory) as memory, SUM(disk) as disk'))->where('node_id', $node->id)->first(),
'locations' => Models\Location::all(), 'locations' => Models\Location::all(),
'allocations' => Models\Allocation::select('allocations.*', 'servers.name as assigned_to_name') 'allocations' => Models\Allocation::select('allocations.*', 'servers.name as assigned_to_name')
->where('allocations.node', $node->id) ->where('allocations.node', $node->id)