guild/common/services/DocumentService.php

28 lines
671 B
PHP
Raw Normal View History

2022-01-07 15:04:11 +03:00
<?php
namespace common\services;
2022-01-10 15:22:51 +03:00
use common\models\Document;
2022-01-07 15:04:11 +03:00
class DocumentService
{
2022-01-16 23:54:13 +03:00
public static function getDocumentList($document_type): array
2022-01-10 15:22:51 +03:00
{
2022-01-16 23:54:13 +03:00
if (!empty($document_type)) {
return Document::find()->joinWith('template')
->where(['document_type' => $document_type])->asArray()->all();
}
else {
return Document::find()->asArray()->all();
2022-01-07 15:04:11 +03:00
}
}
2022-01-16 23:54:13 +03:00
public static function getDocument($document_id)
2022-01-07 15:04:11 +03:00
{
2022-01-16 23:54:13 +03:00
return Document::find()
->joinWith(['documentFieldValues.field'])
->where(['document.id' => $document_id])
->asArray()->all();
2022-01-10 15:22:51 +03:00
}
2022-01-07 15:04:11 +03:00
}