A free open source IT asset/license management system
Use diff_in_days instead
snipe1cd9fc47aae1
diff --git a/app/Models/Asset.php b/app/Models/Asset.phpindex f21454698a..de88662836 100644--- a/app/Models/Asset.php+++ b/app/Models/Asset.php@@ -333,7 +333,7 @@ class Asset extends Depreciable);}- protected function eolDiff(): Attribute+ protected function eolDiffInDays(): Attribute{return Attribute:: make(get: fn(mixed $value, array $attributes) => $this->eolDate ? round((Carbon::now()->diffInDays(Carbon::parse($this->eolDate), false, 1))) : null,diff --git a/app/Models/License.php b/app/Models/License.phpindex 09bc0b3038..73d7c22c3d 100755--- a/app/Models/License.php+++ b/app/Models/License.php@@ -165,6 +165,13 @@ class License extends Depreciable);}+ protected function terminatesDiffInDays(): Attribute+ {+ return Attribute:: make(+ get: fn(mixed $value, array $attributes) => $attributes['termination_date'] ? Carbon::parse($attributes['termination_date'])->diffInDays() : null,+ );+ }+protected function terminatesDiffForHumans(): Attribute{return Attribute:: make(@@ -172,6 +179,7 @@ class License extends Depreciable);}+public function prepareLimitChangeRule($parameters, $field){$actual_seat_count = $this->licenseseats()->count(); //we use the *actual* seat count here, in case your license has gone wonkydiff --git a/app/Models/SnipeModel.php b/app/Models/SnipeModel.phpindex b9a1f1c171..37f513bf9d 100644--- a/app/Models/SnipeModel.php+++ b/app/Models/SnipeModel.php@@ -29,13 +29,14 @@ class SnipeModel extends Model}- protected function expiresDiff(): Attribute+ protected function expiresDiffInDays(): Attribute{return Attribute:: make(- get: fn(mixed $value, array $attributes) => $attributes['expiration_date'] ? round((Carbon::now()->diffInDays(Carbon::parse($attributes['expiration_date']), false, 1))) : null,+ get: fn(mixed $value, array $attributes) => $attributes['expiration_date'] ? Carbon::parse($attributes['expiration_date'])->diffInDays() : null,);}+protected function expiresDiffForHumans(): Attribute{return Attribute:: make(diff --git a/resources/views/notifications/markdown/report-expiring-assets.blade.php b/resources/views/notifications/markdown/report-expiring-assets.blade.phpindex be961ec620..1b35b7a309 100644--- a/resources/views/notifications/markdown/report-expiring-assets.blade.php+++ b/resources/views/notifications/markdown/report-expiring-assets.blade.php@@ -5,7 +5,7 @@| | | || ------------- | ------------- | ------------- |@foreach ($assets as $asset)-| {{ ($asset->eol_diff_for_humans <= ($threshold / 2)) ? '🚨' : (($asset->eol_diff_for_humans <= $threshold) ? '⚠️' : ' ') }} **{{ trans('mail.name') }}** | <a href="{{ route('hardware.show', $asset->id) }}">{{ $asset->display_name }}</a> |+| {{ ($asset->eol_diff_in_days <= ($threshold / 2)) ? '🚨' : (($asset->eol_diff_in_days <= $threshold) ? '⚠️' : 'ℹ️ ') }} **{{ trans('mail.name') }}** | <a href="{{ route('hardware.show', $asset->id) }}">{{ $asset->display_name }}</a> |@if ($asset->serial)| **{{ trans('general.serial_number') }}** | {{ $asset->serial }} |@endifdiff --git a/resources/views/notifications/markdown/report-expiring-licenses.blade.php b/resources/views/notifications/markdown/report-expiring-licenses.blade.phpindex e165e74433..e5445cd50e 100644--- a/resources/views/notifications/markdown/report-expiring-licenses.blade.php+++ b/resources/views/notifications/markdown/report-expiring-licenses.blade.php@@ -6,7 +6,7 @@| | {{ trans('mail.name') }} | {{ trans('mail.expires') }} | {{ trans('mail.terminates') }} || :------------- | :------------- | :------------- | :------------- |@foreach ($licenses as $license)-| {{ ($license->expires_diff_for_humans <= ($threshold / 2)) ? '🚨' : (($license->expires_diff_for_humans <= $threshold) ? '⚠️' : ' ') }} | <a href="{{ route('licenses.show', $license->id) }}">{{ $license->name }}</a> | {{ $license->expires_formatted_date }} {!! $license->expires_diff_for_humans ? ' ('.$license->expires_diff_for_humans .')' : '' !!} | {{ $license->terminates_formatted_date }} {!! $license->terminates_diff_for_humans ? ' ('.$license->terminates_diff_for_humans .')' : '' !!} |+| {{ (($license->isExpired()) || ($license->isTerminated())) ? '🚨' : (($license->expires_diff_in_days <= $threshold) ? '⚠️' : 'ℹ️ ') }} | <a href="{{ route('licenses.show', $license->id) }}">{{ $license->name }}</a> | {{ $license->expires_formatted_date }} {!! $license->expires_diff_for_humans ? ' ('.$license->expires_diff_for_humans .')' : '' !!} | {{ $license->terminates_formatted_date }} {!! $license->terminates_diff_for_humans ? ' ('.$license->terminates_diff_for_humans .')' : '' !!} || <hr> | <hr> | <hr> | <hr> |@endforeach</x-mail::table>