Created
July 18, 2024 05:12
-
-
Save NandoKstroNet/c276d1edcd71fefeb9bb4ca2e9349e35 to your computer and use it in GitHub Desktop.
Conteúdos apoio curso API REST com PHP & VueJS / https://codeexperts.com.br
This file contains 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 | |
Router::post('cadastro', '\Code\App\Controller\AuthController@cadastro'); | |
Router::post('login', '\Code\App\Controller\AuthController@login'); |
This file contains 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 | |
namespace Code\App\Repository; | |
use Code\App\Model\Usuario; | |
use Code\App\Model\UsuarioPerfil; | |
use Code\Framework\Database\Model\Model; | |
use Code\Framework\Database\Repository\RepositoryInterface; | |
class UsuarioRepository implements RepositoryInterface | |
{ | |
public function getModel(): Model | |
{ | |
return new Usuario(); | |
} | |
public function buscarUsuarioPeloEmail(string $email) | |
{ | |
return $this->getModel()->query()->select(['email' => $email], linha: true); | |
} | |
public function cadastrarUsuario(array $data, UsuarioPerfil $perfil) | |
{ | |
$usuario = $this->getModel(); | |
$usuario->nome = $data['nome']; | |
$usuario->sobrenome = $data['sobrenome']; | |
$usuario->email = $data['email']; | |
$usuario->senha = password_hash($data['senha'], PASSWORD_DEFAULT); | |
$usuario->salvar(); | |
$perfil->usuario_id = $usuario->id; | |
$perfil->telefone = $data['telefone']; | |
$perfil->celular = $data['celular']; | |
$perfil->salvar(); | |
return $usuario; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment