Use diff_in_days instead
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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 wonky
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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 }} |
|
||||
@endif
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user