public function run() { DB::table('bulbs')->delete(); Bulb::create(array('ip' => '192.168.2.4', 'address' => 'Roxas Avenue, Quezon City, Philippines', 'latitude' => '14.654724728461096', 'longitude' => '121.06472724547734', 'state' => 'on', 'currbrightness' => 51, 'mode' => 'control', 'name' => 'Oblation Lamp')); Bulb::create(array('ip' => '192.168.2.5', 'address' => 'University Avenue, Quezon City, Philippines', 'latitude' => '14.65395662152603', 'longitude' => '121.05417007079473', 'state' => 'off', 'currbrightness' => 0, 'mode' => 'control', 'name' => 'Philcoa Lamp')); Bulb::create(array('ip' => '192.168.2.6', 'address' => 'Maharlika, Quezon City, Philippines', 'latitude' => '14.650489726993586', 'longitude' => '121.05228179564824', 'state' => 'cnbr', 'currbrightness' => 0, 'mode' => 'control', 'name' => 'Maharlika Lamp')); }
public function index() { //Get the markers $markers = Bulb::all(); $markersCount = Bulb::all()->count(); $clusters = Cluster::all(); $clustersCount = Cluster::all()->count(); //Get bulbs $bulbs = Bulb::all(); $bulbsCount = Bulb::all()->count(); //Get distinct bulbs $distinct_bulbs = array_fetch(DB::select("SELECT DISTINCT bulb_id FROM poweranalyzers ORDER BY bulb_id"), 'bulb_id'); $readings = Bulb::whereIn('id', $distinct_bulbs)->get(); $readingsCount = count($readings); //Get schedules $schedules = Schedule::all(); $schedulesCount = Schedule::all()->count(); return View::make('home')->with('markers', $markers)->with('markersCount', $markersCount)->with('clusters', $clusters)->with('clustersCount', $clustersCount)->with('bulbs', $bulbs)->with('bulbsCount', $bulbsCount)->with('readings', $readings)->with('readingsCount', $readingsCount)->with('schedules', $schedules)->with('schedulesCount', $schedulesCount); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { if (Auth::check()) { $clusters = Cluster::all(); $clustersCount = Cluster::all()->count(); //Get bulbs $bulbs = Bulb::all(); $bulbsCount = Bulb::all()->count(); //Get schedules $schedules = Schedule::all(); $schedulesCount = Schedule::all()->count(); $distinct_bulbs = array_fetch(DB::select("SELECT DISTINCT bulb_id FROM poweranalyzers ORDER BY bulb_id"), 'bulb_id'); $readings = Bulb::whereIn('id', $distinct_bulbs)->get(); $readingsCount = count($readings); $markers = Cluster::find($id)->bulbs; $markersCount = count($markers); return View::make('cluster')->with('markers', $markers)->with('markersCount', $markersCount)->with('clusters', $clusters)->with('clustersCount', $clustersCount)->with('bulbs', $bulbs)->with('bulbsCount', $bulbsCount)->with('readings', $readings)->with('readingsCount', $readingsCount)->with('schedules', $schedules)->with('schedulesCount', $schedulesCount); } }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { //Get the markers $marker = Bulb::find($id); //Get clusters //$clusters = DB::table($cluster_tbl)->lists('clusterid','name'); $clusters = Cluster::all(); $clustersCount = Cluster::all()->count(); //Get bulbs $bulbs = Bulb::all(); $bulbsCount = Bulb::all()->count(); //Get readings $readings = Poweranalyzer::all(); $readingsCount = count($readings); //Get schedules $schedules = Schedule::all(); $schedulesCount = Schedule::all()->count(); return View::make('bulb')->with('marker', $marker)->with('clusters', $clusters)->with('clustersCount', $clustersCount)->with('bulbs', $bulbs)->with('bulbsCount', $bulbsCount)->with('readings', $readings)->with('readingsCount', $readingsCount)->with('schedules', $schedules)->with('schedulesCount', $schedulesCount); //return $marker; }