return$response->withStatus(400)->withJson(['errors'=>'Document has no mailing id']);
}
$workflowSelect="SELECT id FROM workflows ws WHERE workflows.main_document_id = main_document_id AND process_date IS NULL AND status IS NULL ORDER BY \"order\" LIMIT 1";
$workflows=WorkflowModel::get([
'select'=>['main_document_id'],
'where'=>['user_id = ?',"(id) in ({$workflowSelect})"],