/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $date = \Carbon\Carbon::now();
     for ($i = 0; $i < 100; $i++) {
         $a = new Analytics();
         $a->visits = rand(1000, 5000);
         $a->save();
         //Analytics::insert(['visits'=>rand(1000,5000)]);
         sleep(1);
     }
 }
Пример #2
0
 static function getAll($returned_data)
 {
     try {
         $data = array();
         foreach ($returned_data as $row) {
             $sessions_date = $row[0];
             $sessions = $row[1];
             $analytics_object = new Analytics($sessions_date, $sessions);
             $analytics_object->save();
             array_push($data, $analytics_object);
         }
         print_r($data);
     } catch (Exception $e) {
         echo "Data could not be saved to the database.";
         exit;
     }
 }