Skip to content

Commit 23a739b

Browse files
authored
Prevent error when pivot is empty
1 parent 53dff7f commit 23a739b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Controllers/BaseController.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,12 @@ private function getModelDataColumns($column, $opt)
472472
private function pivot_walk($columnId, $column, $data, $parent = 0, $depth = 0)
473473
{
474474
$response = '';
475-
foreach ($data[$parent] as $opt) {
476-
$response .= $this->pivot_label($columnId, $column, $opt);
477-
if (isset($data[$opt->id])) {
478-
$response .= '<div class="pivot-depth ' . ($depth + 1) . '">' . $this->pivot_walk($columnId, $column, $data, $opt->id, $depth + 1) . '</div>';
475+
if (is_array($data)) {
476+
foreach ($data[$parent] as $opt) {
477+
$response .= $this->pivot_label($columnId, $column, $opt);
478+
if (isset($data[$opt->id])) {
479+
$response .= '<div class="pivot-depth ' . ($depth + 1) . '">' . $this->pivot_walk($columnId, $column, $data, $opt->id, $depth + 1) . '</div>';
480+
}
479481
}
480482
}
481483
return $response;

0 commit comments

Comments
 (0)