Skip to content

A free open source IT asset/license management system

Reorganize

Marcus Moore2091f66f5bb1
diff --git a/app/Console/Commands/FixActionLogTimestamps.php b/app/Console/Commands/FixActionLogTimestamps.php
index 256b5f3d46..ad3da7e49c 100644
--- a/app/Console/Commands/FixActionLogTimestamps.php
+++ b/app/Console/Commands/FixActionLogTimestamps.php
@@ -69,13 +69,15 @@ class FixActionLogTimestamps extends Command
$this->line(vsprintf('Updating log id:%s from %s to %s', [$log->id, $log->created_at, $log->updated_at]));
$log->created_at = $log->updated_at;
- $createdBy = $this->getCreatedByAttributeFromSimilarLog($log);
-
- if ($createdBy) {
- $this->line(vsprintf('Updating log id:%s created_by to %s', [$log->id, $createdBy]));
- $log->created_by = $createdBy;
- } else {
- $this->line(vsprintf('No created_by found for log id:%s', [$log->id]));
+ if (is_null($log->created_by)) {
+ $createdBy = $this->getCreatedByAttributeFromSimilarLog($log);
+
+ if ($createdBy) {
+ $this->line(vsprintf('Updating log id:%s created_by to %s', [$log->id, $createdBy]));
+ $log->created_by = $createdBy;
+ } else {
+ $this->warn(vsprintf('No created_by found for log id:%s', [$log->id]));
+ }
}
if (!$this->dryrun) {
@@ -96,23 +98,21 @@ class FixActionLogTimestamps extends Command
private function getCreatedByAttributeFromSimilarLog(Actionlog $log): null|int
{
- if (is_null($log->created_by)) {
- $similarLog = Actionlog::query()
- ->whereNotNull('created_by')
- ->where([
- 'action_type' => 'checkin from',
- 'note' => 'Bulk checkin items',
- 'target_id' => $log->target_id,
- 'target_type' => $log->target_type,
- 'created_at' => $log->updated_at,
- ])
- ->first();
-
- if ($similarLog) {
- return $similarLog->created_by;
- }
-
- return null;
+ $similarLog = Actionlog::query()
+ ->whereNotNull('created_by')
+ ->where([
+ 'action_type' => 'checkin from',
+ 'note' => 'Bulk checkin items',
+ 'target_id' => $log->target_id,
+ 'target_type' => $log->target_type,
+ 'created_at' => $log->updated_at,
+ ])
+ ->first();
+
+ if ($similarLog) {
+ return $similarLog->created_by;
}
+
+ return null;
}
}