/** * Shows the top 10 temperatures for the past 24 hours * within the longitude range of Kyoto. */ public function top10() { //Grab all Measurements, where time is of the last //24 hrs and the longitude = Kyoto's $data = array(); //Kyoto's longitude is 135.733 in decimals $longitude = 135.733; $stations = Station::where('longitude', $longitude)->get(); //TODO: remove this after demoderp. Client wants a little margin on the longitude //$stations = Station::whereBetween('longitude', [135.4, 136])->get(); $measurements = Measurement::with('station')->where('time', '>=', Carbon::now()->subDay())->orderBy('temperature', 'desc')->whereHas('station', function ($sql) use($longitude) { $sql->where('longitude', '=', $longitude); })->take(10)->get(); return view('measurement.top10', ['measurements' => $measurements]); }