guild/common/services/DocumentService.php
2022-01-16 23:54:13 +03:00

28 lines
671 B
PHP

<?php
namespace common\services;
use common\models\Document;
class DocumentService
{
public static function getDocumentList($document_type): array
{
if (!empty($document_type)) {
return Document::find()->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();
}
}