|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Cortex\Auth\Models; |
|
6
|
|
|
|
|
7
|
|
|
use Cortex\Auth\Notifications\PhoneVerificationNotification; |
|
8
|
|
|
use Cortex\Auth\Notifications\AdminPasswordResetNotification; |
|
9
|
|
|
use Cortex\Auth\Notifications\AdminEmailVerificationNotification; |
|
10
|
|
|
|
|
11
|
|
|
class Admin extends User |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* {@inheritdoc} |
|
15
|
|
|
*/ |
|
16
|
|
|
protected $passwordResetNotificationClass = AdminPasswordResetNotification::class; |
|
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* {@inheritdoc} |
|
20
|
|
|
*/ |
|
21
|
|
|
protected $emailVerificationNotificationClass = AdminEmailVerificationNotification::class; |
|
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* {@inheritdoc} |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $phoneVerificationNotificationClass = PhoneVerificationNotification::class; |
|
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Create a new Eloquent model instance. |
|
30
|
|
|
* |
|
31
|
|
|
* @param array $attributes |
|
32
|
|
|
*/ |
|
33
|
|
|
public function __construct(array $attributes = []) |
|
34
|
|
|
{ |
|
35
|
|
|
parent::__construct($attributes); |
|
36
|
|
|
|
|
37
|
|
|
$this->setTable(config('cortex.auth.tables.admins')); |
|
38
|
|
|
$this->setRules([ |
|
39
|
|
|
'username' => 'required|alpha_dash|min:3|max:150|unique:'.config('cortex.auth.tables.admins').',username', |
|
40
|
|
|
'password' => 'sometimes|required|min:'.config('cortex.auth.password_min_chars'), |
|
41
|
|
|
'two_factor' => 'nullable|array', |
|
42
|
|
|
'email' => 'required|email|min:3|max:150|unique:'.config('cortex.auth.tables.admins').',email', |
|
43
|
|
|
'email_verified' => 'sometimes|boolean', |
|
44
|
|
|
'email_verified_at' => 'nullable|date', |
|
45
|
|
|
'phone' => 'nullable|numeric|min:4', |
|
46
|
|
|
'phone_verified' => 'sometimes|boolean', |
|
47
|
|
|
'phone_verified_at' => 'nullable|date', |
|
48
|
|
|
'name_prefix' => 'nullable|string|max:150', |
|
49
|
|
|
'first_name' => 'nullable|string|max:150', |
|
50
|
|
|
'middle_name' => 'nullable|string|max:150', |
|
51
|
|
|
'last_name' => 'nullable|string|max:150', |
|
52
|
|
|
'name_suffix' => 'nullable|string|max:150', |
|
53
|
|
|
'title' => 'nullable|string|max:150', |
|
54
|
|
|
'country_code' => 'nullable|alpha|size:2|country', |
|
55
|
|
|
'language_code' => 'nullable|alpha|size:2|language', |
|
56
|
|
|
'birthday' => 'nullable|date_format:Y-m-d', |
|
57
|
|
|
'gender' => 'nullable|string|in:male,female', |
|
58
|
|
|
'is_active' => 'sometimes|boolean', |
|
59
|
|
|
'last_activity' => 'nullable|date', |
|
60
|
|
|
]); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.