2020-06-20 00:41:31 +02:00
|
|
|
<?php namespace MapGuesser\PersistentData\Model;
|
|
|
|
|
2020-07-05 12:22:47 +02:00
|
|
|
use DateTime;
|
|
|
|
|
2020-06-20 00:41:31 +02:00
|
|
|
class UserConfirmation extends Model
|
|
|
|
{
|
|
|
|
protected static string $table = 'user_confirmations';
|
|
|
|
|
2020-07-05 12:22:47 +02:00
|
|
|
protected static array $fields = ['user_id', 'token', 'last_sent'];
|
2020-06-20 00:41:31 +02:00
|
|
|
|
2020-06-21 01:21:42 +02:00
|
|
|
protected static array $relations = ['user' => User::class];
|
|
|
|
|
2020-06-20 00:41:31 +02:00
|
|
|
private ?User $user = null;
|
|
|
|
|
|
|
|
private ?int $userId = null;
|
|
|
|
|
|
|
|
private string $token = '';
|
|
|
|
|
2020-07-05 12:22:47 +02:00
|
|
|
private DateTime $lastSent;
|
|
|
|
|
2020-06-20 00:41:31 +02:00
|
|
|
public function setUser(User $user): void
|
|
|
|
{
|
|
|
|
$this->user = $user;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setUserId(int $userId): void
|
|
|
|
{
|
|
|
|
$this->userId = $userId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setToken(string $token): void
|
|
|
|
{
|
|
|
|
$this->token = $token;
|
|
|
|
}
|
|
|
|
|
2020-07-05 12:22:47 +02:00
|
|
|
public function setLastSentDate(DateTime $lastSent): void
|
|
|
|
{
|
|
|
|
$this->lastSent = $lastSent;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setLastSent(string $lastSent): void
|
|
|
|
{
|
|
|
|
$this->lastSent = new DateTime($lastSent);
|
|
|
|
}
|
|
|
|
|
2020-06-20 00:41:31 +02:00
|
|
|
public function getUser(): ?User
|
|
|
|
{
|
|
|
|
return $this->user;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUserId(): ?int
|
|
|
|
{
|
|
|
|
return $this->userId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getToken(): string
|
|
|
|
{
|
|
|
|
return $this->token;
|
|
|
|
}
|
2020-07-05 12:22:47 +02:00
|
|
|
|
|
|
|
public function getLastSentDate(): DateTime
|
|
|
|
{
|
|
|
|
return $this->lastSent;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLastSent(): string
|
|
|
|
{
|
|
|
|
return $this->lastSent->format('Y-m-d H:i:s');
|
|
|
|
}
|
2020-06-20 00:41:31 +02:00
|
|
|
}
|