<?php

namespace App\Repositories;

use App\Models\PendingUser;
use Config\Database;
use PDO;

class PendingUserRepository
{
    public function findByEmail($email) {
        $db = Database::getConnection();
        $stmt = $db->prepare("SELECT * FROM pending_users WHERE email = :email");
        $stmt->bindParam(':email', $email);
        $stmt->execute();
        $data = $stmt->fetch(PDO::FETCH_ASSOC);
        return $data ? new PendingUser($data) : null;
    }

    public function findByToken($token) {
        $db = Database::getConnection();
        $stmt = $db->prepare("SELECT * FROM pending_users WHERE token = :token");
        $stmt->bindParam(':token', $token);
        $stmt->execute();
        $data = $stmt->fetch(PDO::FETCH_ASSOC);
        return $data ? new PendingUser($data) : null;
    }
}