add username to user model

This commit is contained in:
Bence Pőcze 2023-09-24 00:47:55 +02:00
parent 703966f8f7
commit 5b045335a1
Signed by: bence
GPG Key ID: DC5BD6E95A333E6D

View File

@ -8,12 +8,14 @@ class User extends Model implements IUser
{ {
protected static string $table = 'users'; protected static string $table = 'users';
protected static array $fields = ['email', 'password', 'type', 'active', 'google_sub', 'created']; protected static array $fields = ['email', 'username', 'password', 'type', 'active', 'google_sub', 'created'];
private static array $types = ['user', 'admin']; private static array $types = ['user', 'admin'];
private string $email = ''; private string $email = '';
private string $username = '';
private ?string $password = null; private ?string $password = null;
private string $type = 'user'; private string $type = 'user';
@ -29,6 +31,11 @@ class User extends Model implements IUser
$this->email = $email; $this->email = $email;
} }
public function setUsername(string $username): void
{
$this->username = $username;
}
public function setPassword(?string $hashedPassword): void public function setPassword(?string $hashedPassword): void
{ {
$this->password = $hashedPassword; $this->password = $hashedPassword;
@ -71,6 +78,11 @@ class User extends Model implements IUser
return $this->email; return $this->email;
} }
public function getUsername(): string
{
return $this->username;
}
public function getPassword(): ?string public function getPassword(): ?string
{ {
return $this->password; return $this->password;