Updated variable name

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-11-13 17:08:20 +00:00
parent 85dbbdbbcb
commit 66aaafc4f2
5 changed files with 15 additions and 18 deletions

View file

@ -40,9 +40,9 @@ class AssetModelImporter extends ItemImporter
{
$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) {
$this->log('A matching Model '.$this->item['name'].' already exists');
return;
@ -52,7 +52,7 @@ class AssetModelImporter extends ItemImporter
$editingAssetModel = true;
} else {
$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
@ -97,20 +97,20 @@ class AssetModelImporter extends ItemImporter
if ($editingAssetModel) {
Log::debug('Updating existing model');
$assetmodel->update($this->sanitizeItemForUpdating($assetmodel));
$assetModel->update($this->sanitizeItemForUpdating($assetModel));
} else {
Log::debug('Creating model');
$assetmodel->fill($this->sanitizeItemForStoring($assetmodel));
$assetModel->fill($this->sanitizeItemForStoring($assetModel));
}
if ($assetmodel->save()) {
$this->log('AssetModel '.$assetmodel->name.' created or updated from CSV import');
return $assetmodel;
if ($assetModel->save()) {
$this->log('AssetModel '.$assetModel->name.' created or updated from CSV import');
return $assetModel;
} else {
$this->log($assetmodel->getErrors()->first());
$this->addErrorToBag($assetmodel, $assetmodel->getErrors()->keys()[0], $assetmodel->getErrors()->first());
return $assetmodel->getErrors();
$this->log($assetModel->getErrors()->first());
$this->addErrorToBag($assetModel, $assetModel->getErrors()->keys()[0], $assetModel->getErrors()->first());
return $assetModel->getErrors();
}
}

View file

@ -73,7 +73,7 @@ class Importer extends Component
case 'asset':
$results = $this->assets_fields;
break;
case 'assetmodel':
case 'assetModel':
$results = $this->assetmodels_fields;
break;
case 'accessory':
@ -165,7 +165,7 @@ class Importer extends Component
$this->importTypes = [
'accessory' => trans('general.accessories'),
'asset' => trans('general.assets'),
'assetmodel' => trans('general.asset_models'),
'assetModel' => trans('general.asset_models'),
'component' => trans('general.components'),
'consumable' => trans('general.consumables'),
'license' => trans('general.licenses'),

View file

@ -179,7 +179,7 @@
@if (($typeOfImport != 'location' && $typeOfImport!= 'assetmodel') && ($typeOfImport!=''))
@if (($typeOfImport != 'location' && $typeOfImport!= 'assetModel') && ($typeOfImport!=''))
<label class="form-control">
<input type="checkbox" name="send_welcome" data-livewire-component="{{ $this->getId() }}" wire:model.live="send_welcome">
{{ trans('general.send_welcome_email_to_users') }}
@ -193,7 +193,6 @@
</div>
Type: {{ $typeOfImport }}
@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;">

View file

@ -4,7 +4,6 @@ namespace Tests\Feature\Importing\Api;
use App\Models\Category;
use App\Models\AssetModel;
use App\Importer\AssetmodelImporter;
use App\Models\User;
use App\Models\Import;
use Illuminate\Foundation\Testing\WithFaker;
@ -24,7 +23,7 @@ class ImportAssetModelsTest extends ImportDataTestCase implements TestsPermissio
protected function importFileResponse(array $parameters = []): TestResponse
{
if (!array_key_exists('import-type', $parameters)) {
$parameters['import-type'] = 'assetmodel';
$parameters['import-type'] = 'assetModel';
}
return parent::importFileResponse($parameters);

View file

@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Tests\Support\Importing;
use App\Models\Category;
use Illuminate\Support\Str;
/**