Skip to content

Commit

Permalink
fix: nonexistent values
Browse files Browse the repository at this point in the history
  • Loading branch information
djsall committed Jun 22, 2024
1 parent 29c6314 commit 4c4a443
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected function getStats(): array

$value = '-';

if (filled($first) && filled($last) && $last->date->notEqualTo($first->date)) {
if ($first && $last && $last->date->notEqualTo($first->date)) {
$value = ($last->value - $first->value) / ($first->date->startOfMonth()->diffInMonths($last->date->endOfMonth()) + 1);
$value = number_format($value, thousands_separator: ' ');
}
Expand Down
4 changes: 2 additions & 2 deletions app/Models/Reading.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function scopeTenant(Builder $query): void
$query->whereBelongsTo(Filament::getTenant(), 'meter');
}

public static function firstOfYear(): self
public static function firstOfYear(): ?self
{
return self::query()
->tenant()
Expand All @@ -48,7 +48,7 @@ public static function firstOfYear(): self
->first();
}

public static function lastOfYear(): self
public static function lastOfYear(): ?self
{
return self::query()
->tenant()
Expand Down

0 comments on commit 4c4a443

Please sign in to comment.