示例#1
0
        exit;
    }
    //if (!$nome)
    if (!$id && $nome !== false) {
        try {
            $servicosModel->insert(['nome'], ['nome' => mb_strtoupper($nome), 'descricao' => $descricao]);
            $_SESSION['status'] = 'Serviço inserido!';
            header('Location: ' . url('/admin/servicos'));
        } catch (\Exception $exc) {
            $_SESSION['erros'][] = "Erro ao inserir Serviço! \n {$exc->getMessage()}";
        }
    }
    //if (!$id)
    if ($id && $nome) {
        try {
            $servicosModel->update($id, ['nome' => mb_strtoupper($nome), 'descricao' => $descricao]);
            $_SESSION['status'] = 'Serviço atualizado!';
            header('Location: ' . url('/admin/servicos'));
        } catch (\Exception $exc) {
            $_SESSION['erros'][] = "Erro ao atualizar serviço! \n {$exc->getMessage()}";
        }
    }
    //fim if($id && $nome)
}
?>

<hr>
<div class="panel panel-primary">
    <div class="panel-heading">Serviço</div>
    <div class="panel-body">
        <form class="form-horizontal" method="post">