diff --git a/app/Models/Component.php b/app/Models/Component.php index 79d2fe55f..dc353d288 100644 --- a/app/Models/Component.php +++ b/app/Models/Component.php @@ -88,6 +88,24 @@ class Component extends SnipeModel 'location' => ['name'], ]; + + /** + * Establishes the components -> action logs -> uploads relationship + * + * @author A. Gianotto + * @since [v6.1.13] + * @return \Illuminate\Database\Eloquent\Relations\Relation + */ + public function uploads() + { + return $this->hasMany(\App\Models\Actionlog::class, 'item_id') + ->where('item_type', '=', self::class) + ->where('action_type', '=', 'uploaded') + ->whereNotNull('filename') + ->orderBy('created_at', 'desc'); + } + + /** * Establishes the component -> location relationship *