Skip to content

Commit

Permalink
Fixes #170 count(): Argument #1 ($value) must be of type Countable|ar…
Browse files Browse the repository at this point in the history
…ray, stdClass given
  • Loading branch information
dmason30 committed Nov 21, 2023
1 parent 5c638da commit 3130d45
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/api/TotalCircleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public function handle(NovaRequest $request)
$options = is_string($request->options) ? json_decode($request->options, true) : $request->input('options', []);
$join = is_string($request->join) ? json_decode($request->join, true) : $request->input('join', []);

$showTotal = $options['showTotal'] ?? true;
$advanceFilterSelected = $options['advanceFilterSelected'] ?? false;
$dataForLast = $options['latestData'] ?? 3;
$calculation = $options['sum'] ?? 1;
Expand All @@ -52,8 +51,9 @@ public function handle(NovaRequest $request)
$seriesSql .= ", SUM(CASE WHEN ".$filter->key." ".$filter->operator." then ".$calculation." else 0 end) as \"".$labelList[$seriesKey]."\"";
} else if(empty($filter->value)){
$seriesSql .= ", SUM(CASE WHEN ";
$countFilter = count($filter);
$countFilter = count((array) $filter);
foreach($filter as $keyFilter => $listFilter){
$listFilter = (object) $listFilter;
$seriesSql .= " ".$listFilter->key." ".($listFilter->operator ?? "=")." '".$listFilter->value."' ";
$seriesSql .= $countFilter-1 != $keyFilter ? " AND " : "";
}
Expand Down
7 changes: 4 additions & 3 deletions src/api/TotalRecordsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function handle(NovaRequest $request)
$options = is_string($request->options) ? json_decode($request->options, true) : $request->input('options', []);
$join = is_string($request->join) ? json_decode($request->join, true) : $request->input('join', []);

$showTotal = $options['showTotal'] ?? true;
$showTotal = (bool) json_decode($options['showTotal'] ?? true);
$totalLabel = $options['totalLabel'] ?? 'Total';
$chartType = $request->type ?? 'bar';
$advanceFilterSelected = $options['advanceFilterSelected'] ?? false;
Expand Down Expand Up @@ -62,8 +62,9 @@ public function handle(NovaRequest $request)
$seriesSql .= ", SUM(CASE WHEN ".$filter->key." ".$filter->operator." then ".$calculation." else 0 end) as \"".$labelList[$seriesKey]."\"";
} else if(empty($filter->value)){
$seriesSql .= ", SUM(CASE WHEN ";
$countFilter = count($filter);
$countFilter = count((array) $filter);
foreach($filter as $keyFilter => $listFilter){
$listFilter = (object) $listFilter;
$seriesSql .= " ".$listFilter->key." ".($listFilter->operator ?? "=")." '".$listFilter->value."' ";
$seriesSql .= $countFilter-1 != $keyFilter ? " AND " : "";
}
Expand Down Expand Up @@ -255,7 +256,7 @@ public function handle(NovaRequest $request)
});
$countKey++;
}
if($showTotal == true){
if($showTotal){
$yAxis[$countKey] = $this->counted($dataSet, $defaultColor[$countKey], 'line', $totalLabel);
}
} else {
Expand Down

0 comments on commit 3130d45

Please sign in to comment.