1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Potievdev\SlimRbac\Models\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Permission |
9
|
|
|
* |
10
|
|
|
* @ORM\Table(name="permission", uniqueConstraints={@ORM\UniqueConstraint(name="idx_role_name", columns={"name"})}) |
11
|
|
|
* @ORM\Entity(repositoryClass="Potievdev\SlimRbac\Models\Repository\PermissionRepository") |
12
|
|
|
* @ORM\HasLifecycleCallbacks |
13
|
|
|
*/ |
14
|
|
View Code Duplication |
class Permission |
|
|
|
|
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @var integer |
18
|
|
|
* |
19
|
|
|
* @ORM\Column(name="id", type="integer", nullable=false) |
20
|
|
|
* @ORM\Id |
21
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
22
|
|
|
*/ |
23
|
|
|
private $id; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var string |
27
|
|
|
* |
28
|
|
|
* @ORM\Column(name="name", type="string", length=100, nullable=false) |
29
|
|
|
*/ |
30
|
|
|
private $name; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var boolean |
34
|
|
|
* |
35
|
|
|
* @ORM\Column(name="status", type="boolean", nullable=false) |
36
|
|
|
*/ |
37
|
|
|
private $status = '1'; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var \DateTime |
41
|
|
|
* |
42
|
|
|
* @ORM\Column(name="created_at", type="datetime", nullable=false) |
43
|
|
|
*/ |
44
|
|
|
private $createdAt; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var \DateTime |
48
|
|
|
* |
49
|
|
|
* @ORM\Column(name="updated_at", type="datetime", nullable=true) |
50
|
|
|
*/ |
51
|
|
|
private $updatedAt; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @var string |
55
|
|
|
* |
56
|
|
|
* @ORM\Column(name="description", type="string", nullable=true) |
57
|
|
|
*/ |
58
|
|
|
private $description; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return int |
62
|
|
|
*/ |
63
|
|
|
public function getId() |
64
|
|
|
{ |
65
|
|
|
return $this->id; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param int $id |
70
|
|
|
*/ |
71
|
|
|
public function setId($id) |
72
|
|
|
{ |
73
|
|
|
$this->id = $id; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return string |
78
|
|
|
*/ |
79
|
|
|
public function getName() |
80
|
|
|
{ |
81
|
|
|
return $this->name; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param string $name |
86
|
|
|
*/ |
87
|
|
|
public function setName($name) |
88
|
|
|
{ |
89
|
|
|
$this->name = $name; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return bool |
94
|
|
|
*/ |
95
|
|
|
public function isStatus() |
96
|
|
|
{ |
97
|
|
|
return $this->status; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @param bool $status |
102
|
|
|
*/ |
103
|
|
|
public function setStatus($status) |
104
|
|
|
{ |
105
|
|
|
$this->status = $status; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return \DateTime |
110
|
|
|
*/ |
111
|
|
|
public function getCreatedAt() |
112
|
|
|
{ |
113
|
|
|
return $this->createdAt; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @param \DateTime $createdAt |
118
|
|
|
*/ |
119
|
|
|
public function setCreatedAt($createdAt) |
120
|
|
|
{ |
121
|
|
|
$this->createdAt = $createdAt; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @return \DateTime |
126
|
|
|
*/ |
127
|
|
|
public function getUpdatedAt() |
128
|
|
|
{ |
129
|
|
|
return $this->updatedAt; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @param \DateTime $updatedAt |
134
|
|
|
*/ |
135
|
|
|
public function setUpdatedAt($updatedAt) |
136
|
|
|
{ |
137
|
|
|
$this->updatedAt = $updatedAt; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @return string |
142
|
|
|
*/ |
143
|
|
|
public function getDescription() |
144
|
|
|
{ |
145
|
|
|
return $this->description; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @param string $description |
150
|
|
|
*/ |
151
|
|
|
public function setDescription($description) |
152
|
|
|
{ |
153
|
|
|
$this->description = $description; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** @ORM\PrePersist */ |
157
|
|
|
public function prePersist() |
158
|
|
|
{ |
159
|
|
|
$this->createdAt = new \DateTime(); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** @ORM\PreUpdate */ |
163
|
|
|
public function preUpdate() |
164
|
|
|
{ |
165
|
|
|
$this->updatedAt = new \DateTime(); |
166
|
|
|
} |
167
|
|
|
} |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.