mapguesser/src/Repository/UserConfirmationRepository.php

30 lines
976 B
PHP

<?php namespace MapGuesser\Repository;
use SokoWeb\Database\Query\Select;
use MapGuesser\PersistentData\Model\User;
use MapGuesser\PersistentData\Model\UserConfirmation;
class UserConfirmationRepository
{
public function getById(int $userConfirmationId): ?UserConfirmation
{
return \Container::$persistentDataManager->selectFromDbById($userConfirmationId, UserConfirmation::class);
}
public function getByToken(string $token): ?UserConfirmation
{
$select = new Select(\Container::$dbConnection);
$select->where('token', '=', $token);
return \Container::$persistentDataManager->selectFromDb($select, UserConfirmation::class);
}
public function getByUser(User $user): ?UserConfirmation
{
$select = new Select(\Container::$dbConnection);
$select->where('user_id', '=', $user->getId());
return \Container::$persistentDataManager->selectFromDb($select, UserConfirmation::class);
}
}