Skip to content

A free open source IT asset/license management system

New method to get latest signature event

368643b314086f962
diff --git a/app/Models/Loggable.php b/app/Models/Loggable.php
index 93b82f8407..506eb116b9 100644
--- a/app/Models/Loggable.php
+++ b/app/Models/Loggable.php
@@ -343,4 +343,24 @@ trait Loggable
return $log;
}
+
+ /**
+ * Get latest signature from a specific user
+ *
+ * This just makes the print view a bit cleaner
+ * Returns the latest acceptance ActionLog that contains a signature
+ * from $user or null if there is none
+ *
+ * @param User $user
+ * @return null|Actionlog
+ **/
+ public function getLatestSignedAcceptance(User $user)
+ {
+ return $this->log->where('target_type', User::class)
+ ->where('target_id', $user->id)
+ ->where('action_type', 'accepted')
+ ->where('accept_signature', '!=', null)
+ ->sortByDesc('created_at')
+ ->first();
+ }
}