mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Fixes/cli importer issue (#9199)
* Added logic to handle the CLI importer. * Fix bug introduced with the commit previous to the regression. * Adds a validation for variable when is null, add comments to clarify where the class variable came from. * Add support for when variable is an instance of User class.
This commit is contained in:
parent
5ea759f615
commit
90a24539b0
|
@ -120,8 +120,10 @@ class AssetImporter extends ItemImporter
|
|||
$this->log('Asset ' . $this->item["name"] . ' with serial number ' . $this->item['serial'] . ' was created');
|
||||
|
||||
// If we have a target to checkout to, lets do so.
|
||||
//-- user_id is a property of the abstract class Importer, which this class inherits from and it's setted by
|
||||
//-- the class that needs to use it (command importer or GUI importer inside the project).
|
||||
if(isset($target)) {
|
||||
$asset->fresh()->checkOut($target);
|
||||
$asset->fresh()->checkOut($target, $this->user_id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -313,8 +313,14 @@ class Asset extends Depreciable
|
|||
}
|
||||
|
||||
if ($this->save()) {
|
||||
|
||||
event(new CheckoutableCheckedOut($this, $target, Auth::user(), $note));
|
||||
if (is_integer($admin)){
|
||||
$checkedOutBy = User::findOrFail($admin);
|
||||
} elseif (get_class($admin) === 'App\Models\User') {
|
||||
$checkedOutBy = $admin;
|
||||
} else {
|
||||
$checkedOutBy = Auth::user();
|
||||
}
|
||||
event(new CheckoutableCheckedOut($this, $target, $checkedOutBy, $note));
|
||||
|
||||
$this->increment('checkout_counter', 1);
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue