-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTechnician.php~
61 lines (53 loc) · 1.62 KB
/
Technician.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace app\models;
use app\core\DbModel;
use app\core\Model;
class Technician extends DbModel
{
const STATUS_INACTIVE = 0;
const STATUS_ACTIVE = 1;
const STATUS_DELETED = 2;
public string $firstName = '';
public string $lastName = '';
public string $phoneNumber = '';
public string $address = '';
public string $email = '';
public int $status = self::STATUS_INACTIVE;
public string $password = '';
public string $confirmPassword = '';
public function tableName(): string
{
return 'technician';
}
public function save()
{
$this->status = self::STATUS_INACTIVE;
$this->password = password_hash($this->password, PASSWORD_DEFAULT);
return parent::save();
}
public function rules(): array
{
return [
'firstName' => [self::RULE_REQUIRED],
'lastName' => [self::RULE_REQUIRED],
'email' => [self::RULE_REQUIRED, self::RULE_EMAIL, [
self::RULE_UNIQUE, 'class' => self::class ]],
'phoneNumber' => [self::RULE_REQUIRED, [self::RULE_MIN, 'min' => 10], [self::RULE_MAX, 'max' => 10]],
'address' => [self::RULE_REQUIRED],
'password' => [self::RULE_REQUIRED, [self::RULE_MIN, 'min' => 8]],
'confirmPassword' => [self::RULE_REQUIRED, [self::RULE_MATCH, 'match' => 'password']],
];
}
public function attributes(): array
{
return [
'firstName',
'lastName',
'phoneNumber',
'address',
'email',
'password',
'status',
];
}
}