Use auth facade

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-11-13 18:21:19 +00:00
parent 0a6096e528
commit d7e5fe50eb

View file

@ -94,7 +94,7 @@ class ItemImporter extends Importer
$this->item['qty'] = $this->findCsvMatch($row, 'quantity');
$this->item['requestable'] = $this->findCsvMatch($row, 'requestable');
$this->item['created_by'] = $this->created_by;
$this->item['created_by'] = auth()->id();
$this->item['serial'] = $this->findCsvMatch($row, 'serial');
// NO need to call this method if we're running the user import.
// TODO: Merge these methods.
@ -249,6 +249,7 @@ class ItemImporter extends Importer
$this->log('No Matching Model, Creating a new one');
$asset_model = new AssetModel();
$asset_model->created_by = auth()->id();
$item = $this->sanitizeItemForStoring($asset_model, $editingModel);
$item['name'] = $asset_model_name;
$item['model_number'] = $asset_modelNumber;
@ -306,9 +307,9 @@ class ItemImporter extends Importer
}
$category = new Category();
$category->created_by = auth()->id();
$category->name = $asset_category;
$category->category_type = $item_type;
$category->created_by = $this->created_by;
if ($category->save()) {
$this->log('Category '.$asset_category.' was created');
@ -337,6 +338,7 @@ class ItemImporter extends Importer
return $company->id;
}
$company = new Company();
$company->created_by = auth()->id();
$company->name = $asset_company_name;
if ($company->save()) {
@ -393,6 +395,7 @@ class ItemImporter extends Importer
}
$this->log('Creating a new status');
$status = new Statuslabel();
$status->created_by = auth()->id();
$status->name = trim($asset_statuslabel_name);
$status->deployable = 1;
@ -432,7 +435,7 @@ class ItemImporter extends Importer
//Otherwise create a manufacturer.
$manufacturer = new Manufacturer();
$manufacturer->name = trim($item_manufacturer);
$manufacturer->created_by = $this->created_by;
$manufacturer->created_by = auth()->id();
if ($manufacturer->save()) {
$this->log('Manufacturer '.$manufacturer->name.' was created');
@ -473,7 +476,7 @@ class ItemImporter extends Importer
$location->city = '';
$location->state = '';
$location->country = '';
$location->created_by = $this->created_by;
$location->created_by = auth()->id();
if ($location->save()) {
$this->log('Location '.$asset_location.' was created');
@ -509,7 +512,7 @@ class ItemImporter extends Importer
$supplier = new Supplier();
$supplier->name = $item_supplier;
$supplier->created_by = $this->created_by;
$supplier->created_by = auth()->id();
if ($supplier->save()) {
$this->log('Supplier '.$item_supplier.' was created');