joinWith('template') ->where(['document_type' => $document_type])->asArray()->all(); } else { return Document::find()->asArray()->all(); } } public static function getDocument($document_id) { return Document::find() ->joinWith(['documentFieldValues.field']) ->where(['document.id' => $document_id]) ->asArray()->all(); } }