✏️ 正在编辑: TermoResponsabilidade.php
路径:
/srv/systems_dir/yuppiecred/application/models/TermoResponsabilidade.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_TermoResponsabilidade { /** @var string */ public const NAO_CONFIGURADO = 'Termo não configurado.'; private $_id; private $_descricao; private $_texto; private $_codigo; private $_parentId; private $_empresaId; /** @var Model_DbTable_TermoResponsabilidade */ private $table; public function getId() { return $this->_id; } public function setId($id) { $this->_id = $id; } public function getEmpresaId() { return $this->_empresaId; } public function setEmpresaId($empresaId) { $this->_empresaId = $empresaId; } public function getDescricao() { return $this->_descricao; } public function setDescricao($descricao) { $this->_descricao = $descricao; } public function getCodigo() { return $this->_codigo; } public function setCodigo($codigo) { $this->_codigo = $codigo; } public function getParentId() { return $this->_parentId; } public function setParentId($parentId) { $this->_parentId = $parentId; } public function getTexto() { return $this->_texto; } public function setTexto($texto) { $this->_texto = $texto; } public function __construct($options = null) { $this->table = table('termo-responsabilidade'); if( is_array($options) ){ $this->setOptions($options); } } public function setOptions(array $options) { $methods = get_class_methods($this); foreach ( $options as $key => $value ) { $explode = explode("_", $key); $methodName = ''; foreach ( $explode as $v ) { $methodName .= ucfirst($v); } $key = $methodName != '' ? $methodName : $key; $method = 'set' . ucfirst($key); if( in_array($method, $methods) ){ $this->$method($value); } } return $this; } public function _toArray() { $dbtable = new Model_DbTable_TermoResponsabilidade(); $info = $dbtable->info(); $methods = get_class_methods($this); $data = array(); foreach ( $info['cols'] as $key ) { $col = $key; $explode = explode('_', $key); $methodName = ''; foreach ( $explode as $v ) { $methodName .= ucfirst($v); } $key = $methodName != '' ? $methodName : $key; $method = 'get' . ucfirst($key); if( in_array($method, $methods) ){ $data[$col] = $this->$method(); } } return $data; } public function excluir($id) { if ($id > 0) { $dbtable = new Model_DbTable_TermoResponsabilidade(); return $dbtable->delete("id = " . $id); } return null; } public function listar($fields = null) { $dbtable = new Model_DbTable_TermoResponsabilidade(); return $dbtable->listar($fields); } public function exibir($id) { $dbtable = new Model_DbTable_TermoResponsabilidade(); return $dbtable->fetchRow("id = " . $id); } public function salvar(Model_TermoResponsabilidade $termoResponsabilidade) { if (!empty($data['texto'])) { throw new Zend_Exception('Informe o corpo do termo de responsabilidade.'); } $dbtable = new Model_DbTable_TermoResponsabilidade(); $data = $termoResponsabilidade->_toArray(); $id = null; if ($termoResponsabilidade->getId() > 0) { $atualizado = $dbtable->update($data, 'id = ' . $termoResponsabilidade->getId()); $id = $atualizado ? $termoResponsabilidade->getId() : null; } else { $id = $dbtable->insert($data); } return $id; } public function getUltimoCodigo() { $dbtable = new Model_DbTable_TermoResponsabilidade(); $dados = $dbtable->fetchRow("excluido = 0"); if( $dados['id'] > 0 ) return $dados['id']; return null; } public function getPrimeiroCodigo() { $dbtable = new Model_DbTable_TermoResponsabilidade(); $dados = $dbtable->fetchRow("excluido = 0"); if( $dados['id'] > 0 ) return $dados['id']; return null; } /** * @return array */ public function getPrimeiroTermoOrThrow(): array { $termo = $this->table->getFirst(); if (empty($termo)) { throw new DomainException(self::NAO_CONFIGURADO); } return $termo; } /** * @return array */ public function getTermoOrThrow(int $id): array { $termo = $this->table->getTermo($id); if (empty($termo)) { throw new DomainException(self::NAO_CONFIGURADO); } $this->setOptions($termo); return $termo; } }
💾 保存文件
← 返回文件管理器