/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Add 10000 values to the first Chart in the database.
     $first = Chart::find(1);
     $date = Carbon::now();
     for ($i = 0; $i < 10000; $i++) {
         DB::table('chart_values')->insert(['timestamp' => $date, 'value' => $this->purebell(10, 35, 3, 0.5), 'chart_id' => $first->id]);
         $date = Carbon::parse($date)->addSecond($first->refresh_time_seconds);
     }
     // Add 5000 values to 2nd table
     $second = Chart::find(2);
     $date = Carbon::now();
     for ($i = 0; $i < 5000; $i++) {
         DB::table('chart_values')->insert(['timestamp' => $date, 'value' => $this->purebell(40, 50, 2, 0.5), 'chart_id' => $second->id]);
         $date = Carbon::parse($date)->addSecond($second->refresh_time_seconds);
     }
     // 1000 values to 3rd table
     $third = Chart::find(3);
     $date = Carbon::now();
     for ($i = 0; $i < 1000; $i++) {
         DB::table('chart_values')->insert(['timestamp' => $date, 'value' => $this->purebell(300, 400, 1, 0.5), 'chart_id' => $third->id]);
         $date = Carbon::parse($date)->addSecond($third->refresh_time_seconds);
     }
     // Adds 1000 values from last year to 4th table
     $fourth = Chart::find(4);
     $date = Carbon::now()->subYear(1);
     for ($i = 0; $i < 1000; $i++) {
         DB::table('chart_values')->insert(['timestamp' => $date, 'value' => $this->purebell(24, 27, 2, 0.5), 'chart_id' => $fourth->id]);
         $date = Carbon::parse($date)->addSecond($third->refresh_time_seconds);
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $chart = Chart::find($id);
     if ($chart) {
         $data = new \StdClass();
         $logoUrl = Setting::where('meta_name', 'logoUrl')->first();
         $data->logoUrl = !empty($logoUrl) ? url('/') . '/' . $logoUrl->meta_value : '';
         return view('view.show', compact('chart', 'data'));
     } else {
         return 'No chart found to view';
     }
 }
 public function config($chartId)
 {
     $chart = Chart::find($chartId);
     if (!$chart) {
         return App::abort(404, "No such chart");
     }
     $config = Chart::getConfigWithUrl($chart);
     return response()->json($config);
 }
 public function config($chartId)
 {
     $chart = Chart::find($chartId);
     $config = $chart ? json_decode($chart->config) : false;
     return response()->json($config);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $chart = Chart::find($id);
     $id = $chart['project_id'];
     $chart->delete();
     return redirect()->action('ProjectsController@show', $id);
 }