From eb5d93b3c2bf22d11063830771675c4f081eb516 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 28 Aug 2024 12:38:55 +0100 Subject: [PATCH] Added assets relationship Signed-off-by: snipe --- app/Models/Depreciation.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/Models/Depreciation.php b/app/Models/Depreciation.php index 9faa1b86e2..7aceddf7c4 100755 --- a/app/Models/Depreciation.php +++ b/app/Models/Depreciation.php @@ -75,4 +75,17 @@ class Depreciation extends SnipeModel { return $this->hasMany(\App\Models\License::class, 'depreciation_id'); } + + /** + * Establishes the depreciation -> assets relationship + * + * @author A. Gianotto + * @since [v5.0] + * @return \Illuminate\Database\Eloquent\Relations\Relation + */ + public function assets() + { + return $this->hasManyThrough(\App\Models\Asset::class, \App\Models\AssetModel::class, 'depreciation_id', 'model_id'); + } + }