public function addListaVip()
 {
     $json = NULL;
     try {
         $eventosId = Session::read('Form.eventos_id');
         $model = new Mobile();
         if (empty($_POST['nomes_listas'])) {
             throw new Exception('A lista deve conter ao menos um nome e telefone!');
         }
         if (empty($_POST['tipos_listas_id'])) {
             throw new Exception('O tipo da lista é um campo requirido!');
         }
         $newArr = $this->Evento->quebraLinha($_POST['nomes_listas']);
         if (empty($newArr)) {
             throw new Exception('Você deve adicionar nomes a lista respeitando a formatação. ex: NOME - FONE');
         }
         foreach ($newArr as $lista) {
             $model->data = $_POST;
             if ($model->validates()) {
                 /**
                  * verificar ou listar o cliente
                  */
                 $registro = $model->setNome($lista['nome'])->setPhone($lista['telefone'])->register();
                 /**
                  * inserir na lista vip
                  */
                 $this->Evento->addClientVipList($registro['pessoas_id'], $eventosId, $_POST['tipos_listas_id'], $this->pessoas_id);
                 $json = json_encode(array('message' => 'Operação realizada com sucesso', "style" => 'success', 'time' => 5000, 'size' => 'md', 'callback' => "carregaMinhaLista();carregaResumoFuncionario();", 'before' => "\$('#loading').fadeOut(500);", 'icon' => 'check', 'title' => 'Success!'));
             } else {
                 $json = json_encode(array('message' => $model->refactoryError(), "style" => 'warning', 'time' => 5000, 'size' => 'md', 'callback' => NULL, 'before' => "\$('#loading').fadeOut(500);", 'icon' => 'check', 'title' => 'Warning!'));
             }
         }
         echo json_encode(array('funcao' => "bootsAlert( {$json} )"));
     } catch (Exception $ex) {
         $json = json_encode(array('message' => $ex->getMessage(), "style" => 'danger', 'time' => 5000, 'size' => 'md', 'callback' => NULL, 'before' => "\$('#loading').fadeOut(500);", 'icon' => 'check', 'title' => 'Danger!'));
         echo json_encode(array('funcao' => "bootsAlert( {$json} )"));
     }
 }
 public function cadastroMobile()
 {
     try {
         $model = new Mobile();
         if (empty($_POST)) {
             throw new Exception('erro do post');
         }
         $model->data = $_POST;
         if ($model->validates()) {
             $dados = $model->setEmail($model->data['email'])->setNome($model->data['nome'])->setPhone($model->data['telefone'])->setPass($model->data['senha'])->register();
             echo json_encode(array('erro' => false, 'code' => 00, 'message' => 'success', 'resultado' => $dados));
         } else {
             echo json_encode(array('erro' => true, 'code' => 01, 'errors' => $model->validateErros));
         }
     } catch (Exception $ex) {
         echo json_encode(array('erro' => true, 'code' => $ex->getCode(), 'message' => $ex->getMessage()));
     }
 }