update get-template-list method

This commit is contained in:
iIronside
2022-01-14 17:34:11 +03:00
parent c1ff229aa7
commit 495eb9a1a4
6 changed files with 99 additions and 4 deletions

View File

@ -32,7 +32,14 @@ class TemplateController extends Controller
public function actionGetTemplateList(): array
{
$template = Template::find()->asArray()->all();
$document_type = Yii::$app->request->get('document_type');
if (!empty($document_type)) {
$template = Template::find()->where(['document_type' => $document_type])->asArray()->all();
}
else {
$template = Template::find()->asArray()->all();
}
if(empty($template)) {
throw new NotFoundHttpException('Documents are not assigned');