add personal user data fields
This commit is contained in:
parent
de346c0c6e
commit
dae96327e5
@ -0,0 +1,5 @@
|
|||||||
|
ALTER TABLE `users`
|
||||||
|
ADD `full_name` varchar(255) NOT NULL DEFAULT '',
|
||||||
|
ADD `nickname` varchar(255) NOT NULL DEFAULT '',
|
||||||
|
ADD `phone` varchar(255) NOT NULL DEFAULT '',
|
||||||
|
ADD `id_number` varchar(255) NOT NULL DEFAULT '';
|
@ -8,7 +8,7 @@ class User extends Model implements IUser
|
|||||||
{
|
{
|
||||||
protected static string $table = 'users';
|
protected static string $table = 'users';
|
||||||
|
|
||||||
protected static array $fields = ['email', 'username', 'password', 'type', 'google_sub', 'created'];
|
protected static array $fields = ['email', 'username', 'password', 'type', 'google_sub', 'created', 'full_name', 'nickname', 'phone', 'id_number'];
|
||||||
|
|
||||||
private static array $types = ['user', 'admin'];
|
private static array $types = ['user', 'admin'];
|
||||||
|
|
||||||
@ -24,6 +24,14 @@ class User extends Model implements IUser
|
|||||||
|
|
||||||
private DateTime $created;
|
private DateTime $created;
|
||||||
|
|
||||||
|
private string $fullName = '';
|
||||||
|
|
||||||
|
private string $nickname = '';
|
||||||
|
|
||||||
|
private string $phone = '';
|
||||||
|
|
||||||
|
private string $idNumber = '';
|
||||||
|
|
||||||
public function setEmail(string $email): void
|
public function setEmail(string $email): void
|
||||||
{
|
{
|
||||||
$this->email = $email;
|
$this->email = $email;
|
||||||
@ -66,6 +74,26 @@ class User extends Model implements IUser
|
|||||||
$this->created = new DateTime($created);
|
$this->created = new DateTime($created);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setFullName(string $fullName): void
|
||||||
|
{
|
||||||
|
$this->fullName = $fullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setNickname(string $nickname): void
|
||||||
|
{
|
||||||
|
$this->nickname = $nickname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPhone(string $phone): void
|
||||||
|
{
|
||||||
|
$this->phone = $phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setIdNumber(string $idNumber): void
|
||||||
|
{
|
||||||
|
$this->idNumber = $idNumber;
|
||||||
|
}
|
||||||
|
|
||||||
public function getEmail(): string
|
public function getEmail(): string
|
||||||
{
|
{
|
||||||
return $this->email;
|
return $this->email;
|
||||||
@ -101,6 +129,26 @@ class User extends Model implements IUser
|
|||||||
return $this->created->format('Y-m-d H:i:s');
|
return $this->created->format('Y-m-d H:i:s');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getFullName(): string
|
||||||
|
{
|
||||||
|
return $this->fullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNickname(): string
|
||||||
|
{
|
||||||
|
return $this->nickname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPhone(): string
|
||||||
|
{
|
||||||
|
return $this->phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIdNumber(): string
|
||||||
|
{
|
||||||
|
return $this->idNumber;
|
||||||
|
}
|
||||||
|
|
||||||
public function hasPermission(int $permission): bool
|
public function hasPermission(int $permission): bool
|
||||||
{
|
{
|
||||||
switch ($permission) {
|
switch ($permission) {
|
||||||
@ -120,7 +168,7 @@ class User extends Model implements IUser
|
|||||||
|
|
||||||
public function getDisplayName(): string
|
public function getDisplayName(): string
|
||||||
{
|
{
|
||||||
return $this->email;
|
return $this->nickname ?: $this->fullName ?: $this->username ?: $this->email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkPassword(string $password): bool
|
public function checkPassword(string $password): bool
|
||||||
|
Loading…
Reference in New Issue
Block a user