/** * @return \yii\db\ActiveQuery */ public function getDocumentType() { return $this->hasOne(\common\models\DocumentType::className(), ['id' => 'document_type_id']); }
protected function createDocument($research_id) { $documentTypes = DocumentType::find()->all(); foreach ($documentTypes as $doc) { $model = Yii::createObject(['class' => Document::className(), 'research_id' => $research_id, 'document_type_id' => $doc->id]); $model->save(); unset($model); } }