Created
February 9, 2022 17:59
-
-
Save tadeubdev/e8bea59671a9d69c45cd8a6a2da84caf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function verificaDadosDeAcessoAoSistema() | |
| { | |
| $db = Database::prepare('SELECT id, endereco FROM usuarios WHERE tipo = 5;'); | |
| $stmt = $db->execute(); | |
| $usuarios = $stmt->fetchAll(\PDO::FETCH_OBJ); | |
| if (empty($dados)) { | |
| return []: | |
| } else { | |
| $usuariosComEndereco = array_filter(function ($usuario) { | |
| return empty($usuario->endereco) === false; | |
| }, $usuarios); | |
| foreach ($usuariosComEndereco as $usuarioComEndereco) { | |
| $db = Database::prepare('SELECT id, name FROM enderecos WHERE usuario_id = :usuario_id;'); | |
| $db->bindParams(':usuario_id', $usuario->id); | |
| $stmt = $db->execute(); | |
| $enderecos = $stmt->fetchAll(\PDO::FETCH_OBJ); | |
| foreach ($enderecos as $endereco) { | |
| if ($endereco->cep) { | |
| $endereco->cep = configuraCEP($endereco->cep); | |
| } | |
| } | |
| $enderecos = array_map(function ($endereco) { | |
| return (string) $endereco; | |
| }); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment