/**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function getIndex()
 {
     $stationModel = new \App\Station();
     $stations = $stationModel->all();
     $relayModel = new \App\Relay();
     $relays = $relayModel->all();
     return array('stations' => $stations, 'relays' => $relays);
     return json_encode(array('success' => 'test', 'message' => 'my test'));
 }
示例#2
0
     $_to = new DateTime('now');
     $_from = clone $_to;
     $_from->modify('-1 week');
     $range = request()->input('range', $_from->format('d/m/Y H:i:s') . ' - ' . $_to->format('d/m/Y H:i:s'));
     $range = explode(' - ', $range);
     $from = DateTime::createFromFormat('d/m/Y H:i:s', $range[0]);
     $to = DateTime::createFromFormat('d/m/Y H:i:s', $range[1]);
     foreach ($_fields as $_field) {
         if (in_array($_field, $_properties)) {
             $_get[] = $_field;
         }
     }
     return $station->aerometrics()->latest()->where('created_at', '>=', $from)->where('created_at', '<=', $to)->get($_get);
 });
 Route::get('/stations', function () {
     return App\Station::all();
 });
 Route::post('/station', function () {
     $station = App\Station::where('unique_id', '=', request()->input('unique_id', ''))->firstOrFail();
     $aerometric = new App\Aerometric();
     $aerometric->station_id = $station->id;
     foreach (array_keys(config('aerometrics.properties')) as $property) {
         $aerometric->{$property} = request()->input($property, '0.0');
     }
     $aerometric->save();
     return ['success' => true];
 });
 Route::get('/station', function () {
     $station = App\Station::where('unique_id', '=', request()->input('unique_id', ''))->firstOrFail();
     $aerometric = new App\Aerometric();
     $aerometric->station_id = $station->id;