From 3531256c3fa53c570bac33f602bb365381dd250a Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 21 Jun 2024 21:06:43 +0100 Subject: [PATCH] Fixed deprecations Signed-off-by: snipe --- app/Models/Asset.php | 2 +- app/Models/Depreciable.php | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 1121dd9e5..a5e2ac8fa 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -568,7 +568,7 @@ class Asset extends Depreciable */ public function assignedType() { - return strtolower(class_basename($this->assigned_type)); + return $this->assigned_type ? strtolower(class_basename($this->assigned_type)) : null; } diff --git a/app/Models/Depreciable.php b/app/Models/Depreciable.php index cfc42aa94..721135873 100644 --- a/app/Models/Depreciable.php +++ b/app/Models/Depreciable.php @@ -173,10 +173,14 @@ class Depreciable extends SnipeModel public function depreciated_date() { - $date = date_create($this->purchase_date); - date_add($date, date_interval_create_from_date_string($this->get_depreciation()->months.' months')); + if (($this->purchase_date) && ($this->get_depreciation())) { + $date = date_create($this->purchase_date); + + return date_add($date, date_interval_create_from_date_string($this->get_depreciation()->months.' months'));//date_format($date, 'Y-m-d'); //don't bake-in format, for internationalization + } + + return null; - return $date; //date_format($date, 'Y-m-d'); //don't bake-in format, for internationalization } // it's necessary for unit tests