Пример #1
0
 public static function editar()
 {
     $voucher = new Voucher();
     $voucher->selecionarPorId($_GET['id']);
     if (!empty($_POST)) {
         if (!empty($_FILES["Event"]["name"]["imagem"])) {
             $imagem = $_FILES["Event"]["name"]["imagem"];
             $imagem = strtolower(str_replace(" ", "-", $_POST['Event']['nome'])) . md5(date('YmdHis')) . '.' . pathinfo($imagem, PATHINFO_EXTENSION);
             move_uploaded_file($_FILES['Event']['tmp_name']['imagem'], __DIR__ . '/../imagens_evento/' . $imagem);
             unlink(__DIR__ . '/../imagens_evento/' . $_POST['Event']['imagem_antiga']);
         }
         unset($_POST['Event']['imagem_antiga']);
         foreach ($_POST['Event'] as $atributo => $valor) {
             $evento->{$atributo} = $valor;
         }
         $evento->imagem = $imagem;
         $idEvento = $evento->salvar();
         self::redirecionar(Configuracao::$baseUrl . 'evento/listar' . Configuracao::$extensaoPadrao);
     }
     self::$variaveis = array('voucher' => $voucher);
     self::$corpo = "editar";
     self::renderizar(self::$viewController);
 }