mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
Check for activeFile before trying to get header
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
e12d2b2a42
commit
4fc66e19bb
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Http\Livewire;
|
namespace App\Http\Livewire;
|
||||||
|
|
||||||
use App\Models\CustomField;
|
use App\Models\CustomField;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
use App\Models\Import;
|
use App\Models\Import;
|
||||||
|
@ -59,12 +60,21 @@ class Importer extends Component
|
||||||
'field_map' => 'array'
|
'field_map' => 'array'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is used in resources/views/livewire/importer.blade.php, and we kinda shouldn't need to check for
|
||||||
|
* activeFile here, but there's some UI goofiness that allows this to crash out on some imports.
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
public function generate_field_map()
|
public function generate_field_map()
|
||||||
{
|
{
|
||||||
\Log::debug("header row is: ".print_r($this->activeFile->header_row,true));
|
$tmp = array();
|
||||||
\Log::debug("Field map is: ".print_r($this->field_map,true));
|
if ($this->activeFile) {
|
||||||
$tmp = array_combine($this->activeFile->header_row, $this->field_map);
|
$tmp = array_combine($this->activeFile->header_row, $this->field_map);
|
||||||
return json_encode(array_filter($tmp));
|
$tmp =array_filter($tmp);
|
||||||
|
}
|
||||||
|
return json_encode($tmp);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue