Skip to content

Commit

Permalink
Fix bugged that trimmed last day of month or last month.
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolicaleksa committed Jun 6, 2019
1 parent 2617316 commit 4827abb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Http/Controllers/StatisticsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ private function retrieveStatistics(string $type, int $year, ?int $month = null)
->get();

if (is_null($month)) {
for ($i = 1; $i < 12; $i++) {
for ($i = 1; $i <= 12; $i++) {
$data[$i] = 0;
}

foreach ($statistics as $statistic) {
$data[Carbon::createFromTimeString($statistic->created_at)->month] += $statistic->value;
}
} else {
for ($i = 1; $i < Carbon::createFromDate($year, $month, 1)->endOfMonth()->day; $i++) {
for ($i = 1; $i <= Carbon::createFromDate($year, $month, 1)->endOfMonth()->day; $i++) {
$data[$i] = 0;
}

Expand Down

0 comments on commit 4827abb

Please sign in to comment.