initial work, not working yet

This commit is contained in:
spencerrlongg 2024-01-25 18:18:24 -06:00
parent b39d11cc06
commit c9101f4d97
4 changed files with 24 additions and 2 deletions

View file

@ -599,7 +599,12 @@ class AssetsController extends Controller
$target = Location::find(request('assigned_location'));
}
if (isset($target)) {
$asset->checkOut($target, Auth::user(), date('Y-m-d H:i:s'), '', 'Checked out on asset creation', e($request->get('name')));
$asset->checkOut($target,
Auth::user(),
date('Y-m-d H:i:s'),
'',
'Checked out on asset creation',
e($request->get('name')));
}
if ($asset->image) {

View file

@ -138,7 +138,8 @@ class AssetImporter extends ItemImporter
if ($asset->save()) {
$asset->logCreate(trans('general.importer.import_note'));
//$asset->logCreate(trans('general.importer.import_note'));
$asset->setImported(true);
$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.

View file

@ -8,6 +8,8 @@ use Illuminate\Support\Facades\Auth;
trait Loggable
{
public ?bool $imported = false; // Import note attribute
/**
* @author Daniel Meltzer <dmeltzer.devel@gmail.com>
* @since [v3.4]
@ -18,6 +20,16 @@ trait Loggable
return $this->morphMany(Actionlog::class, 'item');
}
public function setImported(bool $bool): void
{
$this->imported = $bool;
}
public function getImported(): bool
{
return $this->imported;
}
/**
* @author Daniel Meltzer <dmeltzer.devel@gmail.com>
* @since [v3.4]

View file

@ -109,6 +109,10 @@ class AssetObserver
$logAction->item_id = $asset->id;
$logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id();
$logAction->note = 'poop';
if($asset->getImported()) {
$logAction->note = "this asset was imported";
}
$logAction->logaction('create');
}