Skip to content

A free open source IT asset/license management system

Added requests() method on Assets

snipe08693f09b0c3
diff --git a/app/Models/Asset.php b/app/Models/Asset.php
index 7bce0df242..ed72313aa4 100644
--- a/app/Models/Asset.php
+++ b/app/Models/Asset.php
@@ -786,7 +786,17 @@ class Asset extends Depreciable
return $this->belongsTo(\App\Models\Location::class, 'location_id');
}
-
+ /**
+ * Establishes the asset -> checkout_requests relationship
+ *
+ * @author [A. Gianotto] [<[email protected]>]
+ * @since [v6.2.4]
+ * @return \Illuminate\Database\Eloquent\Relations\Relation
+ */
+ public function requests()
+ {
+ return $this->belongsToMany(\App\Models\Asset::class, 'checkout_requests', 'requestable_id', 'user_id')->where('requestable_type','=',\App\Models\Asset::class);
+ }
/**
* Get the next autoincremented asset tag