mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
changes from a note to a source
This commit is contained in:
parent
2deba17d91
commit
63e733f0d6
|
@ -19,6 +19,9 @@ class Actionlog extends SnipeModel
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
// This is to manually set the source (via setActionSource()) for determineActionSource()
|
||||||
|
protected ?string $source = null;
|
||||||
|
|
||||||
protected $presenter = \App\Presenters\ActionlogPresenter::class;
|
protected $presenter = \App\Presenters\ActionlogPresenter::class;
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
use Presentable;
|
use Presentable;
|
||||||
|
@ -341,7 +344,12 @@ class Actionlog extends SnipeModel
|
||||||
* @since v6.3.0
|
* @since v6.3.0
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function determineActionSource() {
|
public function determineActionSource(): string
|
||||||
|
{
|
||||||
|
// This is a manually set source
|
||||||
|
if($this->source) {
|
||||||
|
return $this->source;
|
||||||
|
}
|
||||||
|
|
||||||
// This is an API call
|
// This is an API call
|
||||||
if (((request()->header('content-type') && (request()->header('accept'))=='application/json'))
|
if (((request()->header('content-type') && (request()->header('accept'))=='application/json'))
|
||||||
|
@ -358,4 +366,10 @@ class Actionlog extends SnipeModel
|
||||||
return 'cli/unknown';
|
return 'cli/unknown';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Manually sets $this->source for determineActionSource()
|
||||||
|
public function setActionSource($source = null): void
|
||||||
|
{
|
||||||
|
$this->source = $source;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ class AccessoryObserver
|
||||||
$logAction->created_at = date('Y-m-d H:i:s');
|
$logAction->created_at = date('Y-m-d H:i:s');
|
||||||
$logAction->user_id = Auth::id();
|
$logAction->user_id = Auth::id();
|
||||||
if($accessory->imported) {
|
if($accessory->imported) {
|
||||||
$logAction->note = trans('general.importer.import_note');
|
$logAction->setActionSource('importer');
|
||||||
}
|
}
|
||||||
$logAction->logaction('create');
|
$logAction->logaction('create');
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ class AssetObserver
|
||||||
$logAction->created_at = date('Y-m-d H:i:s');
|
$logAction->created_at = date('Y-m-d H:i:s');
|
||||||
$logAction->user_id = Auth::id();
|
$logAction->user_id = Auth::id();
|
||||||
if($asset->imported) {
|
if($asset->imported) {
|
||||||
$logAction->note = trans('general.importer.import_note');
|
$logAction->setActionSource('importer');
|
||||||
}
|
}
|
||||||
$logAction->logaction('create');
|
$logAction->logaction('create');
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ class ComponentObserver
|
||||||
$logAction->created_at = date('Y-m-d H:i:s');
|
$logAction->created_at = date('Y-m-d H:i:s');
|
||||||
$logAction->user_id = Auth::id();
|
$logAction->user_id = Auth::id();
|
||||||
if($component->imported) {
|
if($component->imported) {
|
||||||
$logAction->note = trans('general.importer.import_note');
|
$logAction->setActionSource('importer');
|
||||||
}
|
}
|
||||||
$logAction->logaction('create');
|
$logAction->logaction('create');
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ class ConsumableObserver
|
||||||
$logAction->created_at = date('Y-m-d H:i:s');
|
$logAction->created_at = date('Y-m-d H:i:s');
|
||||||
$logAction->user_id = Auth::id();
|
$logAction->user_id = Auth::id();
|
||||||
if($consumable->imported) {
|
if($consumable->imported) {
|
||||||
$logAction->note = trans('general.importer.import_note');
|
$logAction->setActionSource('importer');
|
||||||
}
|
}
|
||||||
$logAction->logaction('create');
|
$logAction->logaction('create');
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ class LicenseObserver
|
||||||
$logAction->created_at = date('Y-m-d H:i:s');
|
$logAction->created_at = date('Y-m-d H:i:s');
|
||||||
$logAction->user_id = Auth::id();
|
$logAction->user_id = Auth::id();
|
||||||
if($license->imported) {
|
if($license->imported) {
|
||||||
$logAction->note = trans('general.importer.import_note');
|
$logAction->setActionSource('importer');
|
||||||
}
|
}
|
||||||
$logAction->logaction('create');
|
$logAction->logaction('create');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue