From 83562cfa8315db4ee49cf5a7710b691fdc6522da Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 8 Apr 2025 05:23:39 +0100 Subject: [PATCH] Added additional searchable relations to activity report Signed-off-by: snipe --- app/Models/Actionlog.php | 68 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/app/Models/Actionlog.php b/app/Models/Actionlog.php index 3a8fcf1cb9..7781004827 100755 --- a/app/Models/Actionlog.php +++ b/app/Models/Actionlog.php @@ -69,7 +69,25 @@ class Actionlog extends SnipeModel 'company' => ['name'], 'adminuser' => ['first_name','last_name','username', 'email'], 'user' => ['first_name','last_name','username', 'email'], - 'assets' => ['asset_tag','name', 'serial'], + 'assets' => ['asset_tag','name', 'serial', 'order_number'], + 'assets.model' => ['name', 'model_number', 'eol'], + 'assets.model.category' => ['name'], + 'assets.model.manufacturer' => ['name'], + 'licenses' => ['name', 'serial', 'notes', 'order_number', 'license_email', 'license_name', 'purchase_order'], + 'licenses.category' => ['name'], + 'licenses.supplier' => ['name'], + 'consumables' => ['name', 'notes', 'order_number', 'model_number', 'item_no'], + 'consumables.category' => ['name'], + 'consumables.location' => ['name'], + 'consumables.supplier' => ['name'], + 'components' => ['name'], + 'components.category' => ['name'], + 'components.location' => ['name'], + 'components.supplier' => ['name'], + 'accessories' => ['name'], + 'accessories.category' => ['name'], + 'accessories.location' => ['name'], + 'accessories.supplier' => ['name'], ]; /** @@ -134,6 +152,54 @@ class Actionlog extends SnipeModel return $this->hasMany(\App\Models\Asset::class, 'id', 'item_id'); } + /** + * Establishes the actionlog -> license relationship + * + * @author [A. Gianotto] [] + * @since [v3.0] + * @return \Illuminate\Database\Eloquent\Relations\Relation + */ + public function licenses() + { + return $this->hasMany(\App\Models\License::class, 'id', 'item_id'); + } + + /** + * Establishes the actionlog -> consumable relationship + * + * @author [A. Gianotto] [] + * @since [v3.0] + * @return \Illuminate\Database\Eloquent\Relations\Relation + */ + public function consumables() + { + return $this->hasMany(\App\Models\Consumable::class, 'id', 'item_id'); + } + + /** + * Establishes the actionlog -> consumable relationship + * + * @author [A. Gianotto] [] + * @since [v3.0] + * @return \Illuminate\Database\Eloquent\Relations\Relation + */ + public function accessories() + { + return $this->hasMany(\App\Models\Accessory::class, 'id', 'item_id'); + } + + /** + * Establishes the actionlog -> components relationship + * + * @author [A. Gianotto] [] + * @since [v3.0] + * @return \Illuminate\Database\Eloquent\Relations\Relation + */ + public function components() + { + return $this->hasMany(\App\Models\Component::class, 'id', 'item_id'); + } + /** * Establishes the actionlog -> item type relationship *