Ejemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * Loop through all statements and create a new key in the document route.
  * This key 'convertedTimestamp' is the same as the statement timestamp but in a 
  * data format the MongoDB aggregation function needs.
  * 
  * @return string
  */
 public function fire()
 {
     Statement::chunk(1000, function ($statements) {
         foreach ($statements as $s) {
             $s->timestamp = new \MongoDate(strtotime($s->statement['timestamp']));
             $s->save();
         }
         $this->info(count($statements) . ' converted.');
     });
     $this->info('All finished, hopefully!');
 }
 public function up()
 {
     Statement::chunk(1000, function ($statements) {
         foreach ($statements as $statement) {
             if (is_object($statement->refs) || is_array($statement->refs) && isset($statement->refs['id'])) {
                 $statement->refs = [$statement->refs];
                 $statement->save();
             }
         }
         echo count($statements) . ' converted.';
     });
     echo 'All finished, hopefully!';
 }