Example #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $reader = Reader::createFromPath('database/data/stigquotes.csv');
     $keys = ['id', 'quote', 'votes', 'date'];
     foreach ($reader->fetchAssoc($keys) as $row) {
         if ($this->checkForDuplicate($row) || $this->doesNotContainSomeSay($row)) {
             continue;
         }
         $quote = $row['quote'];
         $positive = $this->getPositiveScore($row);
         $negative = $this->getNegativeScore($row);
         $display = true;
         $createdAt = $this->getCreatedAt($row);
         $publishedAt = Carbon::now();
         if ($negative > 0) {
             $display = false;
         }
         Quote::create(['quote' => $quote, 'positive' => $positive, 'negative' => $negative, 'display' => $display, 'created_at' => $createdAt, 'published_at' => $publishedAt]);
     }
 }