Skip to content

Commit 46b3916

Browse files
committed
When using json set index if not present to avoid errors
1 parent 08f0f40 commit 46b3916

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/Controllers/ReportController.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,21 @@ private function getQueryData($slug, $id)
3333
$data[$id]->$json = (array)json_decode($row->$json);
3434
}
3535
}
36+
if (!isset($query['index'])) {
37+
$index = [];
38+
foreach($data as $id => $row) {
39+
foreach($row as $key => $value) {
40+
if (is_array($value)) {
41+
foreach($value as $key2 => $value2) {
42+
$index[$key . '.' . $key2] = $key . '.' . $key2;
43+
}
44+
} else {
45+
$index[$key] = $key;
46+
}
47+
}
48+
}
49+
$query['index'] = implode(',', $index);
50+
}
3651
}
3752
// Return only index columns if present
3853
if (isset($query['index'])) {

0 commit comments

Comments
 (0)