|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Orm\Entity; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\ORM\Mapping\Column; |
|
8
|
|
|
use Doctrine\ORM\Mapping\Entity; |
|
9
|
|
|
use Doctrine\ORM\Mapping\GeneratedValue; |
|
10
|
|
|
use Doctrine\ORM\Mapping\Id; |
|
11
|
|
|
use Doctrine\ORM\Mapping\Index; |
|
12
|
|
|
use Doctrine\ORM\Mapping\JoinColumn; |
|
13
|
|
|
use Doctrine\ORM\Mapping\OneToOne; |
|
14
|
|
|
use Doctrine\ORM\Mapping\Table; |
|
15
|
|
|
use Stu\Orm\Repository\UserLockRepository; |
|
16
|
|
|
|
|
17
|
|
|
#[Table(name: 'stu_user_lock')] |
|
18
|
|
|
#[Index(name: 'user_lock_user_idx', columns: ['user_id'])] |
|
19
|
|
|
#[Entity(repositoryClass: UserLockRepository::class)] |
|
20
|
|
|
class UserLock |
|
21
|
|
|
{ |
|
22
|
|
|
#[Id] |
|
23
|
|
|
#[Column(type: 'integer')] |
|
24
|
|
|
#[GeneratedValue(strategy: 'IDENTITY')] |
|
25
|
|
|
private int $id; |
|
26
|
|
|
|
|
27
|
|
|
#[Column(type: 'integer', nullable: true)] |
|
28
|
|
|
private ?int $former_user_id = null; |
|
29
|
|
|
|
|
30
|
|
|
#[Column(type: 'integer')] |
|
31
|
|
|
private int $remaining_ticks = 0; |
|
32
|
|
|
|
|
33
|
|
|
#[Column(type: 'text')] |
|
34
|
|
|
private string $reason = ''; |
|
35
|
|
|
|
|
36
|
|
|
#[OneToOne(targetEntity: User::class, inversedBy: 'userLock')] |
|
37
|
|
|
#[JoinColumn(name: 'user_id', nullable: true, referencedColumnName: 'id', onDelete: 'CASCADE')] |
|
38
|
|
|
private ?User $user = null; |
|
39
|
|
|
|
|
40
|
|
|
public function getId(): int |
|
41
|
|
|
{ |
|
42
|
|
|
return $this->id; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function getUser(): ?User |
|
46
|
|
|
{ |
|
47
|
|
|
return $this->user; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function setUser(?User $user): UserLock |
|
51
|
|
|
{ |
|
52
|
|
|
$this->user = $user; |
|
53
|
|
|
return $this; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function setFormerUserId(?int $userId): UserLock |
|
57
|
|
|
{ |
|
58
|
|
|
$this->former_user_id = $userId; |
|
59
|
|
|
return $this; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function getRemainingTicks(): int |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->remaining_ticks; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function setRemainingTicks(int $count): UserLock |
|
68
|
|
|
{ |
|
69
|
|
|
$this->remaining_ticks = $count; |
|
70
|
|
|
return $this; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function getReason(): string |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->reason; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function setReason(string $reason): UserLock |
|
79
|
|
|
{ |
|
80
|
|
|
$this->reason = $reason; |
|
81
|
|
|
|
|
82
|
|
|
return $this; |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|