get('childList'); if (is_null($childList)) { $data['childList'] = null; } else { $arr = []; foreach ($childList as $entity) { $arr[] = $entity->toArray(); } $data['childList'] = $arr; } return $data; } }