添加对不存在二级品类的数据进行验证的逻辑
Code Review By Rock Zhang
Showing
1 changed file
with
4 additions
and
0 deletions
@@ -126,6 +126,10 @@ class ClassModel | @@ -126,6 +126,10 @@ class ClassModel | ||
126 | foreach ($data as $item) { | 126 | foreach ($data as $item) { |
127 | $id = $item['category_id']; | 127 | $id = $item['category_id']; |
128 | $result['first'][$id] = $item['category_name']; | 128 | $result['first'][$id] = $item['category_name']; |
129 | + if (!isset($item['sub'])) { | ||
130 | + continue; | ||
131 | + } | ||
132 | + | ||
129 | foreach ($item['sub'] as $sub) { | 133 | foreach ($item['sub'] as $sub) { |
130 | $id = $sub['category_id']; | 134 | $id = $sub['category_id']; |
131 | $result['second'][$id] = $sub['category_name']; | 135 | $result['second'][$id] = $sub['category_name']; |
-
Please register or login to post a comment