1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class User extends \Phalcon\Mvc\Model |
|
|
|
|
4
|
|
|
{ |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* |
8
|
|
|
* @var integer |
9
|
|
|
*/ |
10
|
|
|
protected $id; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* |
14
|
|
|
* @var string |
15
|
|
|
*/ |
16
|
|
|
protected $mail; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
protected $password; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
protected $identite; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
protected $role; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Method to set the value of field id |
38
|
|
|
* |
39
|
|
|
* @param integer $id |
40
|
|
|
* @return $this |
41
|
|
|
*/ |
42
|
|
|
public function setId($id) |
43
|
|
|
{ |
44
|
|
|
$this->id = $id; |
45
|
|
|
|
46
|
|
|
return $this; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Method to set the value of field mail |
51
|
|
|
* |
52
|
|
|
* @param string $mail |
53
|
|
|
* @return $this |
54
|
|
|
*/ |
55
|
|
|
public function setMail($mail) |
56
|
|
|
{ |
57
|
|
|
$this->mail = $mail; |
58
|
|
|
|
59
|
|
|
return $this; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Method to set the value of field password |
64
|
|
|
* |
65
|
|
|
* @param string $password |
66
|
|
|
* @return $this |
67
|
|
|
*/ |
68
|
|
|
public function setPassword($password) |
69
|
|
|
{ |
70
|
|
|
$this->password = $password; |
71
|
|
|
|
72
|
|
|
return $this; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Method to set the value of field identite |
77
|
|
|
* |
78
|
|
|
* @param string $identite |
79
|
|
|
* @return $this |
80
|
|
|
*/ |
81
|
|
|
public function setIdentite($identite) |
82
|
|
|
{ |
83
|
|
|
$this->identite = $identite; |
84
|
|
|
|
85
|
|
|
return $this; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Method to set the value of field role |
90
|
|
|
* |
91
|
|
|
* @param string $role |
92
|
|
|
* @return $this |
93
|
|
|
*/ |
94
|
|
|
public function setRole($role) |
95
|
|
|
{ |
96
|
|
|
$this->role = $role; |
97
|
|
|
|
98
|
|
|
return $this; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Returns the value of field id |
103
|
|
|
* |
104
|
|
|
* @return integer |
105
|
|
|
*/ |
106
|
|
|
public function getId() |
107
|
|
|
{ |
108
|
|
|
return $this->id; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Returns the value of field mail |
113
|
|
|
* |
114
|
|
|
* @return string |
115
|
|
|
*/ |
116
|
|
|
public function getMail() |
117
|
|
|
{ |
118
|
|
|
return $this->mail; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Returns the value of field password |
123
|
|
|
* |
124
|
|
|
* @return string |
125
|
|
|
*/ |
126
|
|
|
public function getPassword() |
127
|
|
|
{ |
128
|
|
|
return $this->password; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Returns the value of field identite |
133
|
|
|
* |
134
|
|
|
* @return string |
135
|
|
|
*/ |
136
|
|
|
public function getIdentite() |
137
|
|
|
{ |
138
|
|
|
return $this->identite; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* Returns the value of field role |
143
|
|
|
* |
144
|
|
|
* @return string |
145
|
|
|
*/ |
146
|
|
|
public function getRole() |
147
|
|
|
{ |
148
|
|
|
return $this->role; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Initialize method for model. |
153
|
|
|
*/ |
154
|
|
|
public function initialize() |
155
|
|
|
{ |
156
|
|
|
$this->hasMany('id', 'Message', 'idUser', array('alias' => 'Messages')); |
157
|
|
|
$this->hasMany('id', 'Projet', 'idClient', array('alias' => 'Projets')); |
158
|
|
|
$this->hasMany('id', 'Usecase', 'idDev', array('alias' => 'Usecases')); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
public function toString(){ |
162
|
|
|
return $this->identite."(".$this->mail.")"; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
//Return a string containing the principal content of the model |
166
|
|
|
public function getPrincipal(){ |
167
|
|
|
return "Identité : ".$this->identite." <br/> Email : ".$this->mail; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* Returns table name mapped in the model. |
173
|
|
|
* |
174
|
|
|
* @return string |
175
|
|
|
*/ |
176
|
|
|
public function getSource() |
177
|
|
|
{ |
178
|
|
|
return 'user'; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* Allows to query a set of records that match the specified conditions |
183
|
|
|
* |
184
|
|
|
* @param mixed $parameters |
185
|
|
|
* @return User[] |
186
|
|
|
*/ |
187
|
|
|
public static function find($parameters = null) |
188
|
|
|
{ |
189
|
|
|
return parent::find($parameters); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* Allows to query the first record that match the specified conditions |
194
|
|
|
* |
195
|
|
|
* @param mixed $parameters |
196
|
|
|
* @return User |
197
|
|
|
*/ |
198
|
|
|
public static function findFirst($parameters = null) |
199
|
|
|
{ |
200
|
|
|
return parent::findFirst($parameters); |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
} |
204
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.