From 9d9ad86dd53e6376ed523d5d85db791cfa2fd6b7 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 31 May 2024 02:14:59 +0100 Subject: [PATCH] Added mutators and accessors for dates Signed-off-by: snipe --- app/Models/Asset.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 12c5aeb93a..ace867ea98 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -983,6 +983,49 @@ class Asset extends Depreciable $this->attributes['next_audit_date'] = $value ? Carbon::parse($value)->format('Y-m-d') : null; } + public function getLastCheckoutAttribute($value) + { + return $this->attributes['last_checkout'] = $value ? Carbon::parse($value)->format('Y-m-d H:i:s') : null; + } + + public function setLastCheckoutAttribute($value) + { + $this->attributes['last_checkout'] = $value ? Carbon::parse($value)->format('Y-m-d H:i:s') : null; + } + + public function getLastCheckinAttribute($value) + { + return $this->attributes['last_checkin'] = $value ? Carbon::parse($value)->format('Y-m-d H:i:s') : null; + } + + public function setLastCheckinAttribute($value) + { + $this->attributes['last_checkin'] = $value ? Carbon::parse($value)->format('Y-m-d H:i:s') : null; + } + + public function getLastAuditDateAttribute($value) + { + return $this->attributes['last_audit_date'] = $value ? Carbon::parse($value)->format('Y-m-d H:i:s') : null; + } + + public function setLastAuditDateAttribute($value) + { + $this->attributes['last_audit_date'] = $value ? Carbon::parse($value)->format('Y-m-d H:i:s') : null; + } + + public function getAssetEolDateAttribute($value) + { + return $this->attributes['asset_eol_date'] = $value ? Carbon::parse($value)->format('Y-m-d') : null; + } + + public function setAssetEolDateAttribute($value) + { + $this->attributes['asset_eol_date'] = $value ? Carbon::parse($value)->format('Y-m-d') : null; + } + + + + /** * This sets the requestable to a boolean 0 or 1. This accounts for forms or API calls that * explicitly pass the requestable field but it has a null or empty value.