From 00092a079fcf658e04864d0b996d888f440d1990 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 21 Apr 2025 14:42:10 +0100 Subject: [PATCH] Added uploads method Signed-off-by: snipe --- app/Models/Location.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/Models/Location.php b/app/Models/Location.php index 69c79cfae..9b1ed02f4 100755 --- a/app/Models/Location.php +++ b/app/Models/Location.php @@ -20,6 +20,7 @@ class Location extends SnipeModel { use HasFactory; use CompanyableTrait; + use Loggable; protected $presenter = \App\Presenters\LocationPresenter::class; use Presentable; @@ -288,6 +289,23 @@ class Location extends SnipeModel return $this->attributes['ldap_ou'] = empty($ldap_ou) ? null : $ldap_ou; } + /** + * Get uploads for this location + * + * @author [A. Gianotto] [] + * @since [v4.0] + * @return \Illuminate\Database\Eloquent\Relations\Relation + */ + public function uploads() + { + return $this->hasMany('\App\Models\Actionlog', 'item_id') + ->where('item_type', '=', Location::class) + ->where('action_type', '=', 'uploaded') + ->whereNotNull('filename') + ->orderBy('created_at', 'desc'); + } + + /** * Query builder scope to order on parent *