diff --git a/app/src/Domain/Repository/User/UserRepository.php b/app/src/Domain/Repository/User/UserRepository.php index 6c26412..713f1c7 100644 --- a/app/src/Domain/Repository/User/UserRepository.php +++ b/app/src/Domain/Repository/User/UserRepository.php @@ -11,15 +11,18 @@ use Slovocast\Infrastructure\Api\Database\DatabaseHandlerInterface; class UserRepository implements UserRepositoryInterface { - const CREATE_QUERY = "INSERT INTO users (email, password, name) + const QUERY_CREATE = "INSERT INTO users (email, password, name) VALUES (:email, :password, :name)"; - const UPDATE_QUERY = "UPDATE users + const QUERY_UPDATE = "UPDATE users SET email = :email, name = :name, password = :password WHERE id = :id"; + const QUERY_SELECT_BY_ID = ""; + const QUERY_SELECT_BY_EMAIL = ""; + public function __construct( private DatabaseHandlerInterface $db, private UserAuthorizationInterface $userAuth @@ -76,7 +79,7 @@ class UserRepository implements UserRepositoryInterface public function create(User $user): bool { - $results = $this->db->execute(self::CREATE_QUERY, [ + $results = $this->db->execute(self::QUERY_CREATE, [ ':email' => $user->getEmail(), ':password' => $this->userAuth->hash($user->getPassword()), ':name' => $user->getName(), @@ -94,13 +97,7 @@ class UserRepository implements UserRepositoryInterface public function update(User $user): bool { - $query = "UPDATE users - SET email = :email, - name = :name, - password = :password - WHERE id = :id"; - - $results = $this->db->execute(self::UPDATE_QUERY, [ + $results = $this->db->execute(self::QUERY_UPDATE, [ ':email' => $user->getEmail(), ':name' => $user->getName(), ':password' => $this->userAuth->hash($user->getPassword()), diff --git a/app/src/Domain/Repository/User/UserRepositoryInterface.php b/app/src/Domain/Repository/User/UserRepositoryInterface.php index 4d2af5c..9ab9ae4 100644 --- a/app/src/Domain/Repository/User/UserRepositoryInterface.php +++ b/app/src/Domain/Repository/User/UserRepositoryInterface.php @@ -8,6 +8,12 @@ interface UserRepositoryInterface { public function get(int $id): User; public function getFromEmail(string $email): User; + + /** + * @TODO Add methods for getting a User based on other related data, such + * as the Channel or Episode. + */ + public function create(User $user): bool; public function update(User $user): bool; public function delete(User $user): bool;