/** * Execute the console command. * * @return mixed */ public function fire() { $market = $this->argument('market'); $fileName = storage_path() . '/app/' . time() . '.xls'; file_put_contents($fileName, $this->getHtmlContent($this->argument('url'))); $reader = PHPExcel_IOFactory::createReader('Excel5'); $excel = $reader->load($fileName); $sheet = $excel->getSheet(); $i = 2; while ($sheet->getCell("A{$i}") != "") { $code = $sheet->getCell("B{$i}"); $name = $sheet->getCell("C{$i}"); $issue = Issue::where('code', $code)->first(); if (!$issue) { $issue = new Issue(); } $issue->code = $code; $issue->name = $name; $issue->market = $market; if ($issue->getOriginal() != $issue->getAttributes()) { $issue->save(); } $i++; } unlink($fileName); }