Skip to content

Commit

Permalink
Fix missing parameters entry in console stats command
Browse files Browse the repository at this point in the history
  • Loading branch information
svenbw committed Jun 21, 2024
1 parent b636591 commit 4886958
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Commands/LaravelRouteStatisticsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ class LaravelRouteStatisticsCommand extends Command
public function handle()
{
$query = $this->getQuery();
$fields = $this->getFields();

if ($this->option('group')) {
$query->select($this->option('group'))
->addSelect(DB::raw('MAX(date) as last_used'))
->addSelect(DB::raw('SUM(counter) as counter'));
} else {
$query->select($fields);
}

$this->applyFilters($query);
Expand All @@ -43,7 +46,7 @@ public function handle()
$results = $query->limit($this->option('limit'))->get();

$this->table(
$this->getFields(),
$fields,
$results->toArray()
);

Expand Down Expand Up @@ -111,16 +114,17 @@ protected function getFields(): array
return array_merge($this->option('group'), ['last_used', 'counter']);
}

return [
return array_filter([
'id',
'user_id',
'team_id',
'method',
'route',
'status',
config('route-statistics.store_parameters') === true ? 'parameters' : null,
'ip',
'date',
'counter',
];
]);
}
}

0 comments on commit 4886958

Please sign in to comment.