Updated variable name
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
85dbbdbbcb
commit
66aaafc4f2
5 changed files with 15 additions and 18 deletions
|
@ -40,9 +40,9 @@ class AssetModelImporter extends ItemImporter
|
||||||
{
|
{
|
||||||
|
|
||||||
$editingAssetModel = false;
|
$editingAssetModel = false;
|
||||||
$assetmodel = AssetModel::where('name', '=', $this->findCsvMatch($row, 'name'))->first();
|
$assetModel = AssetModel::where('name', '=', $this->findCsvMatch($row, 'name'))->first();
|
||||||
|
|
||||||
if ($assetmodel) {
|
if ($assetModel) {
|
||||||
if (! $this->updating) {
|
if (! $this->updating) {
|
||||||
$this->log('A matching Model '.$this->item['name'].' already exists');
|
$this->log('A matching Model '.$this->item['name'].' already exists');
|
||||||
return;
|
return;
|
||||||
|
@ -52,7 +52,7 @@ class AssetModelImporter extends ItemImporter
|
||||||
$editingAssetModel = true;
|
$editingAssetModel = true;
|
||||||
} else {
|
} else {
|
||||||
$this->log('No Matching Model, Create a new one');
|
$this->log('No Matching Model, Create a new one');
|
||||||
$assetmodel = new AssetModel();
|
$assetModel = new AssetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pull the records from the CSV to determine their values
|
// Pull the records from the CSV to determine their values
|
||||||
|
@ -97,20 +97,20 @@ class AssetModelImporter extends ItemImporter
|
||||||
|
|
||||||
if ($editingAssetModel) {
|
if ($editingAssetModel) {
|
||||||
Log::debug('Updating existing model');
|
Log::debug('Updating existing model');
|
||||||
$assetmodel->update($this->sanitizeItemForUpdating($assetmodel));
|
$assetModel->update($this->sanitizeItemForUpdating($assetModel));
|
||||||
} else {
|
} else {
|
||||||
Log::debug('Creating model');
|
Log::debug('Creating model');
|
||||||
$assetmodel->fill($this->sanitizeItemForStoring($assetmodel));
|
$assetModel->fill($this->sanitizeItemForStoring($assetModel));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($assetmodel->save()) {
|
if ($assetModel->save()) {
|
||||||
$this->log('AssetModel '.$assetmodel->name.' created or updated from CSV import');
|
$this->log('AssetModel '.$assetModel->name.' created or updated from CSV import');
|
||||||
return $assetmodel;
|
return $assetModel;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->log($assetmodel->getErrors()->first());
|
$this->log($assetModel->getErrors()->first());
|
||||||
$this->addErrorToBag($assetmodel, $assetmodel->getErrors()->keys()[0], $assetmodel->getErrors()->first());
|
$this->addErrorToBag($assetModel, $assetModel->getErrors()->keys()[0], $assetModel->getErrors()->first());
|
||||||
return $assetmodel->getErrors();
|
return $assetModel->getErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ class Importer extends Component
|
||||||
case 'asset':
|
case 'asset':
|
||||||
$results = $this->assets_fields;
|
$results = $this->assets_fields;
|
||||||
break;
|
break;
|
||||||
case 'assetmodel':
|
case 'assetModel':
|
||||||
$results = $this->assetmodels_fields;
|
$results = $this->assetmodels_fields;
|
||||||
break;
|
break;
|
||||||
case 'accessory':
|
case 'accessory':
|
||||||
|
@ -165,7 +165,7 @@ class Importer extends Component
|
||||||
$this->importTypes = [
|
$this->importTypes = [
|
||||||
'accessory' => trans('general.accessories'),
|
'accessory' => trans('general.accessories'),
|
||||||
'asset' => trans('general.assets'),
|
'asset' => trans('general.assets'),
|
||||||
'assetmodel' => trans('general.asset_models'),
|
'assetModel' => trans('general.asset_models'),
|
||||||
'component' => trans('general.components'),
|
'component' => trans('general.components'),
|
||||||
'consumable' => trans('general.consumables'),
|
'consumable' => trans('general.consumables'),
|
||||||
'license' => trans('general.licenses'),
|
'license' => trans('general.licenses'),
|
||||||
|
|
|
@ -179,7 +179,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@if (($typeOfImport != 'location' && $typeOfImport!= 'assetmodel') && ($typeOfImport!=''))
|
@if (($typeOfImport != 'location' && $typeOfImport!= 'assetModel') && ($typeOfImport!=''))
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
<input type="checkbox" name="send_welcome" data-livewire-component="{{ $this->getId() }}" wire:model.live="send_welcome">
|
<input type="checkbox" name="send_welcome" data-livewire-component="{{ $this->getId() }}" wire:model.live="send_welcome">
|
||||||
{{ trans('general.send_welcome_email_to_users') }}
|
{{ trans('general.send_welcome_email_to_users') }}
|
||||||
|
@ -193,7 +193,6 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
Type: {{ $typeOfImport }}
|
|
||||||
|
|
||||||
@if($statusText)
|
@if($statusText)
|
||||||
<div class="alert col-md-8 col-md-offset-3{{ $statusType == 'success' ? ' alert-success' : ($statusType == 'error' ? ' alert-danger' : ' alert-info') }}" style="padding-top: 20px;">
|
<div class="alert col-md-8 col-md-offset-3{{ $statusType == 'success' ? ' alert-success' : ($statusType == 'error' ? ' alert-danger' : ' alert-info') }}" style="padding-top: 20px;">
|
||||||
|
|
|
@ -4,7 +4,6 @@ namespace Tests\Feature\Importing\Api;
|
||||||
|
|
||||||
use App\Models\Category;
|
use App\Models\Category;
|
||||||
use App\Models\AssetModel;
|
use App\Models\AssetModel;
|
||||||
use App\Importer\AssetmodelImporter;
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\Import;
|
use App\Models\Import;
|
||||||
use Illuminate\Foundation\Testing\WithFaker;
|
use Illuminate\Foundation\Testing\WithFaker;
|
||||||
|
@ -24,7 +23,7 @@ class ImportAssetModelsTest extends ImportDataTestCase implements TestsPermissio
|
||||||
protected function importFileResponse(array $parameters = []): TestResponse
|
protected function importFileResponse(array $parameters = []): TestResponse
|
||||||
{
|
{
|
||||||
if (!array_key_exists('import-type', $parameters)) {
|
if (!array_key_exists('import-type', $parameters)) {
|
||||||
$parameters['import-type'] = 'assetmodel';
|
$parameters['import-type'] = 'assetModel';
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::importFileResponse($parameters);
|
return parent::importFileResponse($parameters);
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Tests\Support\Importing;
|
namespace Tests\Support\Importing;
|
||||||
|
|
||||||
use App\Models\Category;
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue