Skip to content

Commit

Permalink
Prevent error when pivot is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdekruijk authored Mar 4, 2022
1 parent 53dff7f commit 23a739b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Controllers/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,12 @@ private function getModelDataColumns($column, $opt)
private function pivot_walk($columnId, $column, $data, $parent = 0, $depth = 0)
{
$response = '';
foreach ($data[$parent] as $opt) {
$response .= $this->pivot_label($columnId, $column, $opt);
if (isset($data[$opt->id])) {
$response .= '<div class="pivot-depth ' . ($depth + 1) . '">' . $this->pivot_walk($columnId, $column, $data, $opt->id, $depth + 1) . '</div>';
if (is_array($data)) {
foreach ($data[$parent] as $opt) {
$response .= $this->pivot_label($columnId, $column, $opt);
if (isset($data[$opt->id])) {
$response .= '<div class="pivot-depth ' . ($depth + 1) . '">' . $this->pivot_walk($columnId, $column, $data, $opt->id, $depth + 1) . '</div>';
}
}
}
return $response;
Expand Down

0 comments on commit 23a739b

Please sign in to comment.