A free open source IT asset/license management system
Fixed #9965 - fallback to category images (f there are any) when no consumable image is present
snipe3b243b38c8cf
diff --git a/app/Http/Transformers/ConsumablesTransformer.php b/app/Http/Transformers/ConsumablesTransformer.phpindex b31e31ac96..8a40606c87 100644--- a/app/Http/Transformers/ConsumablesTransformer.php+++ b/app/Http/Transformers/ConsumablesTransformer.php@@ -25,7 +25,7 @@ class ConsumablesTransformer$array = ['id' => (int) $consumable->id,'name' => e($consumable->name),- 'image' => ($consumable->image) ? Storage::disk('public')->url('consumables/'.e($consumable->image)) : null,+ 'image' => ($consumable->getImageUrl()) ? ($consumable->getImageUrl()) : null,'category' => ($consumable->category) ? ['id' => $consumable->category->id, 'name' => e($consumable->category->name)] : null,'company' => ($consumable->company) ? ['id' => (int) $consumable->company->id, 'name' => e($consumable->company->name)] : null,'item_no' => e($consumable->item_no),diff --git a/app/Models/Consumable.php b/app/Models/Consumable.phpindex f4b6a3ca6b..ca5ddcf52b 100644--- a/app/Models/Consumable.php+++ b/app/Models/Consumable.php@@ -230,11 +230,16 @@ class Consumable extends SnipeModel*/public function getImageUrl(){+ // If there is a consumable image, use thatif ($this->image) {return Storage::disk('public')->url(app('consumables_upload_path').$this->image);++ // Otherwise check for a category image+ } elseif (($this->category) && ($this->category->image)) {+ return Storage::disk('public')->url(app('categories_upload_path').e($this->category->image));}- return false;+ return false;}/**