Esempio n. 1
0
 public function inserirMotorista($dados)
 {
     try {
         $this->validarMotorista($dados);
         $this->em->beginTransaction();
         $motorista = new MotoristaEntity();
         $motorista->setMatricula($dados['matricula']);
         $motorista->setNome($dados['nome']);
         $motorista->setNomeImpresso($dados['nomeImpresso']);
         $motorista->setCnh($dados['cnh']);
         $motorista->setDataValidadeCnh(DateUtil::criarData($dados['dataValidadeCnh']));
         $motorista->setTipoCategoriaCnh($dados['tipoCategoriaCnh']);
         $motorista->setEndereco($dados['endereco']);
         $motorista->setTelefone($dados['telefone']);
         $motorista->setBairro($dados['bairro']);
         $motorista->setCep($dados['cep']);
         $motorista->setMunicipio($this->em->getReference("Frota\\Model\\Entity\\Municipio", $dados['municipio']['id']));
         $motorista->setLotacao($this->em->getReference("Frota\\Model\\Entity\\Lotacao", $dados['lotacao']));
         $motorista->setCargo($this->em->getReference("Frota\\Model\\Entity\\Cargo", $dados['cargo']['codigo']));
         $this->em->persist($motorista);
         $this->em->flush();
         $this->em->commit();
     } catch (Exception $exc) {
         if ($this->em->getConnection()->isTransactionActive()) {
             $this->em->rollback();
         }
         throw $exc;
     }
     return $motorista;
 }
 public function jsonSerialize()
 {
     $this->__load();
     return parent::jsonSerialize();
 }