✏️ 正在编辑: CallcenterEndereco.php
路径:
/srv/systems_dir/yuppiecred-lidernegocios/application/models/CallcenterEndereco.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_CallcenterEndereco { private $_id; private $_cpfCliente; private $_endereco; private $_numero; private $_complemento; private $_bairro; private $_cidade; private $_uf; private $_cep; public function getId() { return $this->_id; } public function getCpfCliente() { return $this->_cpfCliente; } public function getEndereco() { return $this->_endereco; } public function getNumero() { return $this->_numero; } public function getComplemento() { return $this->_complemento; } public function getBairro() { return $this->_bairro; } public function getCidade() { return $this->_cidade; } public function getUf() { return $this->_uf; } public function getCep() { return $this->_cep; } public function setId($id) { $this->_id = $id; return $this; } public function setCpfCliente($cpfCliente) { $this->_cpfCliente = $cpfCliente; return $this; } public function setEndereco($endereco) { $this->_endereco = $endereco; return $this; } public function setNumero($numero) { $this->_numero = $numero; return $this; } public function setComplemento($complemento) { $this->_complemento = $complemento; return $this; } public function setBairro($bairro) { $this->_bairro = $bairro; return $this; } public function setCidade($cidade) { $this->_cidade = $cidade; return $this; } public function setUf($uf) { $this->_uf = $uf; return $this; } public function setCep($cep) { $this->_cep = $cep; return $this; } public function __construct($options = null) { 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_CallcenterEndereco(); $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 salvar() { $dbtable = new Model_DbTable_CallcenterEndereco(); if( $this->getId() > 0 ){ $dbtable->update($this->_toArray(), "id = " . $this->getId()); return $this->getId(); } else { $data = $this->_toArray(); return $dbtable->insert($data); } } /** * Exclui o registro passado por parâmetro * @param int $id * @return int The number of rows deleted */ public function excluir($id) { if( $id > 0 ){ $dbtable = new Model_DbTable_CallcenterEndereco(); return $dbtable->delete("id = " . $id); } return null; } /** * Retorna uma lista * @param string $where * @param string $order * @return array */ public function listar($fields = null, $order = "id ASC") { $where = null; $params = array(); if( isset($fields['cpf_cliente']) && !empty($fields['cpf_cliente']) ){ $params[] = "cpf_cliente = '" . $fields['cpf_cliente'] . "'"; } if( count($params) > 0 ){ $where = implode(' AND ', $params); $dbtable = new Model_DbTable_CallcenterEndereco(); return $dbtable->fetchAll($where, $order); } return null; } public function exibir($id) { $dbtable = new Model_DbTable_CallcenterEndereco(); return $dbtable->fetchRow("id = " . $id); } public static function existeOuCria($cpf, $cep) { $cpf = String_Refatorar::formatarCpf($cpf); $registro = (new Model_DbTable_CallcenterEndereco)->fetchRow(["cpf_cliente = ?" => $cpf, "cep = ?" => $cep]); if ($registro){ return new self($registro->toArray()); } return new self; } }
💾 保存文件
← 返回文件管理器