Improvements to Echoarea Import, area names are now uppercase and descriptions use ucfirst()
This commit is contained in:
parent
a87cf875e4
commit
c59f8ee0ed
@ -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++;
|
||||
|
||||
if (str_contains($line,' '))
|
||||
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;
|
||||
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user