Example #1
0
 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);
     }
 }
Example #3
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     //Create a new light/lamp
     $longitude = Input::get('longitude');
     $latitude = Input::get('latitude');
     //Assign coordinates to $marker array
     $marker = array('longitude' => $longitude, 'latitude' => $latitude);
     //Get clusters
     $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('add_bulb')->with('marker', $marker)->with('longitude', $longitude)->with('latitude', $latitude)->with('clusters', $clusters)->with('clustersCount', $clustersCount)->with('bulbs', $bulbs)->with('bulbsCount', $bulbsCount)->with('readings', $readings)->with('readingsCount', $readingsCount)->with('schedules', $schedules)->with('schedulesCount', $schedulesCount);
 }