where(['tasktype_id' => $task_type ])->all(); } else { $resultTasks = CheckpointTypesForTasks::find()->all(); } return $resultTasks; } // работает public function createFromID($id) { $checkpointTypesEntity = CheckpointTypes::findOne($id); if ( $checkpointTypesEntity ) { $cpType = self::CreateFromArray($checkpointTypesEntity); return $cpType; } return null; } // работает public static function CreateFromArray($checkpointArr) { $checkpointType = new CheckPointTypeModel(); $checkpointType->id = $checkpointArr->id; $checkpointType->name = $checkpointArr->name; $checkpointType->class = $checkpointArr->class; $checkpointType->childrenCheckpointTypes = array(); $checkpointType->FillChildren(); return $checkpointType; } // работает function FillChildren() { $checkpointTypeHierarchy = CheckpointTypeHierarchy::find()->where(['parent_cp_type' => $this->id] ); foreach ($checkpointTypeHierarchy as $hierarchy) { $checkpointTypes = CheckPointTypes::find()->where(['id' => $child->cp_type])->all(); foreach ($checkpointTypes as $type) { $child = self::CreateFromArray($checkarr); array_push($this->childrenCheckpointTypes, $child); } } } }