file = $file; $this->do = $do->withoutRelations(); $this->prefix = $prefix ?: ''; $this->delete_file = $delete_file; $this->delete_recs = $delete_recs; } public function __get($key): mixed { switch ($key) { case 'jobname': return sprintf('%s-%s',$this->do->name,$this->file); default: return NULL; } } /** * Execute the job. * * @return void * @throws \Exception */ public function handle() { $fh = fopen($this->file,'r'); $p = $c = 0; while (! feof($fh)) { $line = stream_get_line($fh, 0, "\n"); // Remove any embedded CR and BOM $line = str_replace("\r",'',$line); $line = preg_replace('/^\x{feff}/u','',$line); if (! $line) continue; $c++; if (str_contains($line,' ')) list($area,$description) = preg_split('/[\s|\t]+/',$line,2); else { $area = $line; $description = '[No 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; $o->security = 9; $this->do->echoareas()->save($o); } fclose($fh); if ($this->delete_file and $c) unlink($this->file); Log::info(sprintf('%s:= Updated %d records',self::LOGKEY,$p)); } }