Skip to content

Commit 00ec4b1

Browse files
committed
改进视图模型多级子关联映射问题
1 parent 1952746 commit 00ec4b1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/model/View.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,11 @@ public function initData(bool $relation = true)
7474
$relation = array_shift($items);
7575
if (isset($data[$relation])) {
7676
// 存在关联数据
77-
$value = $data[$relation];
77+
$value = $data[$relation];
7878
foreach ($items as $item) {
79-
$value = is_array($value) ? $value[$item] : $value->$item;
79+
if ($value) {
80+
$value = is_array($value) ? $value[$item] : $value->$item;
81+
}
8082
}
8183
$this->$key = $value;
8284
}

0 commit comments

Comments
 (0)