Improvements to Echoarea Import, area names are now uppercase and descriptions use ucfirst()

This commit is contained in:
Deon George 2023-08-03 22:11:59 +10:00
parent a87cf875e4
commit c59f8ee0ed
1 changed files with 9 additions and 15 deletions

View File

@ -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;