/** * */ public function home() { // summary by location $locations = \App\Location::where('parent_id', 0)->orderBy('name')->get(); for ($i = 0; $i < count($locations); $i++) { $nodesAll = \App\Node::where('location_id', $locations[$i]->id)->get(); $nodesUp = \App\Node::where('location_id', $locations[$i]->id)->where('ping_success', '100')->get(); $locations[$i]->nodesUp = $nodesUp->count(); $locations[$i]->nodesDown = $nodesAll->count() - $nodesUp->count(); } // summary by project $projects = \App\Project::orderBy('name')->get(); for ($i = 0; $i < count($projects); $i++) { $nodesAll = \App\Node::where('project_id', $projects[$i]->id)->get(); $nodesUp = \App\Node::where('project_id', $projects[$i]->id)->where('ping_success', '100')->get(); $projects[$i]->nodesUp = $nodesUp->count(); $projects[$i]->nodesDown = $nodesAll->count() - $nodesUp->count(); } // summary by nodegroup $nodegroups = \App\Nodegroup::orderBy('name')->get(); for ($i = 0; $i < count($nodegroups); $i++) { $nodesAll = \App\Node::where('nodegroup_id', $nodegroups[$i]->id)->get(); $nodesUp = \App\Node::where('nodegroup_id', $nodegroups[$i]->id)->where('ping_success', '100')->get(); $nodegroups[$i]->nodesUp = $nodesUp->count(); $nodegroups[$i]->nodesDown = $nodesAll->count() - $nodesUp->count(); } return view('pages.home', compact('locations', 'projects', 'nodegroups', 'bssids')); }
/** * Generate Nodegroup Associate Array * * @return Array */ public static function all_select() { $_ret = array(); $_ret[''] = '-- nodegroup --'; $nodegroups = \App\Nodegroup::orderBy('name')->get(); foreach ($nodegroups as $nodegroup) { $_ret[$nodegroup->id] = $nodegroup->name; } return $_ret; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // $nodegroup = \App\Nodegroup::findOrFail($id); \Session::flash('flash_message', 'nodegroup ' . $nodegroup->name . ' deleted.'); // delete $nodegroup->delete(); return redirect('nodegroups'); }