/** * Run the database seeds. * * @return void */ public function run() { foreach (App\Chart::all() as $c) { $chartDaily = DB::select(DB::raw('SELECT DATE(timestamp) as date, chart_id, MAX(value) as max, MIN(value) as min, AVG(value) as avg FROM chart_values WHERE chart_id = ' . $c->id . ' GROUP BY DATE(timestamp)')); foreach ($chartDaily as $day) { DB::table('charts_daily_stats')->insert(['date' => $day->date, 'max' => $day->max, 'min' => $day->min, 'avg' => $day->avg, 'chart_id' => $day->chart_id]); } } }
return App\Entity::whereId($value)->first(); }); Route::bind('datasources', function ($value, $route) { return App\Datasource::whereId($value)->first(); }); Route::bind('datasets', function ($value, $route) { return App\Dataset::whereId($value)->first(); }); Route::bind('variables', function ($value, $route) { return App\Variable::whereId($value)->first(); }); Route::bind('values', function ($value, $route) { return App\DataValue::whereId($value)->first(); }); Route::bind('charts', function ($value, $route) { return App\Chart::whereId($value)->first(); }); Route::bind('chartTypes', function ($value, $route) { return App\ChartType::whereId($value)->first(); }); Route::bind('categories', function ($value, $route) { return App\DatasetCategory::whereId($value)->first(); }); Route::bind('subcategories', function ($value, $route) { return App\DatasetSubcategory::whereId($value)->first(); }); Route::bind('tags', function ($value, $route) { return App\DatasetTag::whereId($value)->first(); }); Route::bind('licenses', function ($value, $route) { return App\License::whereId($value)->first();