/** * Display the specified dashboard. * * @param int $id * @return Response */ public function show($id) { $products = Product::all(); $records = Record::all(); $manufacturers = Manufacturer::all(); return View::make('Dashboard.index', compact('records', 'products', 'manufacturers')); }
public static function command($id) { if (Record::all()->count()) { $query = DB::select(DB::raw("SELECT DISTINCT *\n FROM records\n WHERE switch = '" . $id . "'\n AND updated_at IN(\n SELECT MAX(updated_at) \n FROM records \n GROUP BY id\n )ORDER BY updated_at DESC;")); if ($query != null) { $record = $query[0]; return $record->command; } else { return 0; } } else { return 0; } }
public function uploadLog($site_id, $switch, $status, $rfid, $created_at) { $page = 'log'; $entry = new Record(); $entry->site_id = $site_id; $entry->site_name = 'test'; $entry->switch = $switch; if ($status) { $status_string = 'on'; $command = 1; } else { $status_string = 'off'; $command = 0; } $entry->status = $status_string; $entry->command = $command; $entry->rfid = $rfid; $entry->created_at = $created_at; $entry->save(); $records = Record::all(); }
public function getPie() { $start = 0; $end = 3; $page = 'reports'; $graph = 'pie'; $records = Record::all(); $entries = []; $date = $records[0]->updated_at->month; while (sizeof($records) != 0) { $s1_hits = 0; $s2_hits = 0; $s3_hits = 0; $s4_hits = 0; $s5_hits = 0; $s6_hits = 0; foreach ($records as $key => $currentRecord) { $currentDate = $currentRecord->updated_at->month; if ($currentDate == $date) { switch ($currentRecord->switch) { case '1': $s1_hits++; break; case '2': $s2_hits++; break; case '3': $s3_hits++; break; case '4': $s4_hits++; break; case '5': $s5_hits++; break; case '6': $s6_hits++; break; } unset($records[$key]); } else { $data = "['Switch 1'" . ', ' . $s1_hits . ']'; array_push($entries, $data); $data = "['Switch 2'" . ', ' . $s2_hits . ']'; array_push($entries, $data); $data = "['Switch 3'" . ', ' . $s3_hits . ']'; array_push($entries, $data); $data = "['Switch 4'" . ', ' . $s4_hits . ']'; array_push($entries, $data); $data = "['Switch 5'" . ', ' . $s5_hits . ']'; array_push($entries, $data); $data = "['Switch 6'" . ', ' . $s6_hits . ']'; array_push($entries, $data); $date = $currentDate; break; } } } $data = "['Door'" . ', ' . $s1_hits . ']'; array_push($entries, $data); $data = "['Lights'" . ', ' . $s2_hits . ']'; array_push($entries, $data); $data = "['Alarm'" . ', ' . $s3_hits . ']'; array_push($entries, $data); $data = "['Generator'" . ', ' . $s4_hits . ']'; array_push($entries, $data); $data = "['AC'" . ', ' . $s5_hits . ']'; array_push($entries, $data); $data = "['Mains'" . ', ' . $s6_hits . ']'; array_push($entries, $data); return View::make('reports.index')->with('page', $page)->with('reports', $entries)->with('start', $start)->with('end', $end)->with('graph', $graph); }
/** * Display a listing of records * * @return Response */ public function index() { $records = Record::all(); return View::make('Dashboard.index', compact('records')); }