-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUser.php
42 lines (36 loc) · 931 Bytes
/
User.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* @author Artur Kyryliuk <mail@artur.work>
*/
namespace Auth\Models;
abstract class User extends \BaseModel
{
const SESSION_ROLES = 'roles';
const SESSION_ID = 'id';
const ROLE_BANNED = 'banned';
const ROLE_USER = 'user';
const ROLE_ADMIN = 'admin';
protected $_int = ['id'];
protected $_bool = ['is_banned', 'is_test'];
protected $_string = ['email', 'fullname', 'password', 'token'];
public ?int $id = null;
public string $email;
public string $fullname;
public ?string $password;
public string $token;
/** @var bool */
public $isBanned;
/** @var bool */
public $isTest;
abstract public function initialize();
public function getRoles()
{
$roles = [];
if ($this->isBanned) {
$roles[] = self::ROLE_BANNED;
} else {
$roles[] = self::ROLE_USER;
}
return $roles;
}
}