$where=['(templates_association.value_field in (?) OR templates_association.template_id IS NULL)','templates.template_type = ?','templates.template_target = ?'];
$data=[$entities,'OFFICE','attachments'];
$queryParams=$request->getQueryParams();
if(!empty($queryParams['attachmentType'])){
$where[]='templates.template_attachment_type in (?)';