diff --git a/app/Jobs/EchoareaImport.php b/app/Jobs/EchoareaImport.php index 38a240a..31bf77d 100644 --- a/app/Jobs/EchoareaImport.php +++ b/app/Jobs/EchoareaImport.php @@ -52,13 +52,7 @@ class EchoareaImport implements ShouldQueue */ public function handle() { - // Get the file from the host - $file = $this->getFileFromHost('',self::importkey,$this->file); - Log::debug(sprintf('%s:Loading file [%s] (%s).',static::LOGKEY,$file,getcwd())); - $lines = $this->getFileLines($file); - Log::debug(sprintf('%s:Processing [%d] lines.',static::LOGKEY,$lines)); - - $fh = fopen($file,'r'); + $fh = fopen($this->file,'r'); $p = $c = 0; while (! feof($fh)) { @@ -73,16 +67,16 @@ class EchoareaImport implements ShouldQueue $c++; - list($area,$description) = preg_split('/[\s|\t]+/',$line,2); - - if ($this->do->echoareas->pluck('name')->search($area) !== FALSE) { - Log::info(sprintf('%s: Area [%s] already exists.',self::LOGKEY,$area)); - continue; + if (str_contains($line,' ')) + list($area,$description) = preg_split('/[\s|\t]+/',$line,2); + else { + $area = $line; + $description = '[No Description]'; } - $o = new Echoarea; - $o->name = $area; - $o->description = ($this->prefix ?: '').$description; + $o = Echoarea::whereRaw(sprintf("LOWER(name)='%s'",strtolower($area)))->firstOrNew(); + $o->name = strtoupper($area); + $o->description = ($this->prefix.' ' ?: '').ucfirst($description); $o->active = TRUE; $o->show = TRUE;