1face72c
Yarik
test
|
1
2
|
<?php
|
e8236f44
Yarik
test
|
3
|
namespace common\models;
|
658d13d4
Administrator
09.02.16
|
4
|
|
e8236f44
Yarik
test
|
5
|
use Yii;
|
d02fd466
Yarik
test
|
6
7
|
use yii\behaviors\AttributeBehavior;
use yii\db\ActiveRecord;
|
658d13d4
Administrator
09.02.16
|
8
|
|
1face72c
Yarik
test
|
9
|
/**
|
e8236f44
Yarik
test
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
* This is the model class for table "user_info".
* @property integer $user_id
* @property integer $view_count
* @property string $busy
* @property string $date_visit
* @property string $experience
* @property string $rank
* @property string $salary
* @property string $job
* @property string $location
* @property string $soft
* @property integer $user_info_id
* @property string $guarantee
* @property integer $contract
* @property integer $estimate
* @property integer $purchase
* @property integer $delivery
* @property double $prepayment
* @property string $about
* @property integer $type
|
d02fd466
Yarik
test
|
30
|
* @property string $geography
|
9cc08528
Yarik
test
|
31
|
* @property integer $salary_currency
|
76f36646
Yarik
test
|
32
|
* @property string $email
|
b3ef6f91
Yarik
test
|
33
|
* @property integer $hide_mail
|
1face72c
Yarik
test
|
34
|
*/
|
e8236f44
Yarik
test
|
35
|
class UserInfo extends \yii\db\ActiveRecord
|
1face72c
Yarik
test
|
36
|
{
|
8f939a27
Administrator
add Vitaliy's wid...
|
37
|
|
e8236f44
Yarik
test
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// Константа обознащающая физическое лицо
const USER_TYPE_FIZ = 1;
// Константа обозначающая компанию
const USER_TYPE_COMPANY = 2;
// Константа обозначающая, что компания/физ.лицо свободно
const USER_STATUS_FREE = 1;
// Константа обозначающая, что компания/физ.лицо занято
const USER_STATUS_BUSY = 2;
// Константа обозначающая, что компания/физ.лицо хочет стать членом МФП
const USER_MEMBER_FALSE = 1;
// Константа обозначающая, что компания/физ.лицо не хочет стать членом МФП
const USER_MEMBER_TRUE = 2;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'user_info';
}
|
eb7e82fb
Administrator
29.02.16
|
64
65
66
67
68
69
70
|
/**
* @inheritdoc
*/
public function behaviors()
{
return [
[
|
76f36646
Yarik
test
|
71
|
'class' => 'common\behaviors\ShowImage',
|
eb7e82fb
Administrator
29.02.16
|
72
73
74
75
|
],
];
}
|
e8236f44
Yarik
test
|
76
77
78
79
80
81
82
|
/**
* @inheritdoc
*/
public function rules()
{
return [
[
|
3e86d3d1
Yarik
test
|
83
|
[
|
420d3dcd
Yarik
test
|
84
|
'email',
|
cefc2aa6
Yarik
test
|
85
|
'city',
|
3e86d3d1
Yarik
test
|
86
87
88
89
|
],
'required',
],
[
|
e8236f44
Yarik
test
|
90
|
[
|
e8236f44
Yarik
test
|
91
92
|
'is_customer',
'is_freelancer',
|
9cc08528
Yarik
test
|
93
|
'salary_currency',
|
e8236f44
Yarik
test
|
94
95
96
97
|
],
'integer',
],
[
|
d02fd466
Yarik
test
|
98
99
100
101
|
[
'date_visit',
'geographies',
],
|
e8236f44
Yarik
test
|
102
103
104
105
106
|
'safe',
],
[
[
'soft',
|
e8236f44
Yarik
test
|
107
108
109
110
111
|
'about',
'city',
'country',
'image',
'poster',
|
e8236f44
Yarik
test
|
112
113
114
115
116
117
|
],
'string',
],
[
[ 'prepayment' ],
'number',
|
9d05331a
Yarik
test
|
118
|
'min' => 0,
|
d02fd466
Yarik
test
|
119
|
'max' => 100,
|
e8236f44
Yarik
test
|
120
121
122
123
124
125
126
127
|
],
[
[ 'experience' ],
'integer',
'max' => date('Y'),
'min' => 1950,
],
[
|
e8236f44
Yarik
test
|
128
129
130
131
132
133
134
135
136
|
[
'rank',
'location',
],
'string',
'max' => 50,
],
[
[
|
e8236f44
Yarik
test
|
137
138
139
140
141
142
143
144
145
|
'job',
],
'string',
'max' => 255,
],
[
[
'busy',
'member',
|
78ab7436
Yarik
test
|
146
147
148
149
150
|
],
'boolean',
],
[
[
|
f1f3595c
Yarik
test
|
151
152
153
154
|
'contract',
'estimate',
'purchase',
'delivery',
|
e8236f44
Yarik
test
|
155
|
],
|
78ab7436
Yarik
test
|
156
157
|
'string',
'max' => 50,
|
e8236f44
Yarik
test
|
158
159
|
],
[
|
d02fd466
Yarik
test
|
160
161
162
163
164
165
166
167
|
[
'view_count',
'busy',
'member',
'salary',
'guarantee',
'prepayment',
],
|
e8236f44
Yarik
test
|
168
169
170
|
'default',
'value' => 0,
],
|
f1f3595c
Yarik
test
|
171
|
[
|
d02fd466
Yarik
test
|
172
173
174
175
|
[
'salary',
'guarantee',
],
|
f1f3595c
Yarik
test
|
176
177
178
|
'integer',
'min' => 0,
],
|
5346fcf9
Yarik
test
|
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
[
[
'social_vk',
],
'match',
'pattern' => '/^(?:https?:\/\/)?(?:www\.)?vk\.com\/[\S]+\/?$/',
],
[
[
'social_fb',
],
'match',
'pattern' => '/^(?:https?:\/\/)?(?:www\.)?facebook\.com\/[\S]+\/?$/',
],
[
[
'social_in',
],
'match',
'pattern' => '/^(?:https?:\/\/)?(?:www\.)?linkedin\.com\/(?:pub|in)\/[\S]+\/?$/',
],
[
[
'social_t',
],
'match',
'pattern' => '/^(?:https?:\/\/)?(?:www\.)?twitter\.com\/[\S]+\/?$/',
],
|
1c67655e
Yarik
test
|
207
208
209
210
211
|
[
[
'geographies',
],
'default',
|
76f36646
Yarik
test
|
212
|
'value' => [ ],
|
1c67655e
Yarik
test
|
213
|
],
|
420d3dcd
Yarik
test
|
214
215
216
217
218
219
|
[
[
'email',
],
'email',
],
|
b3ef6f91
Yarik
test
|
220
221
222
223
224
225
226
|
[
[ 'hide_mail' ],
'integer',
'min' => 0,
'max' => 1,
],
[
|
76f36646
Yarik
test
|
227
|
[ 'hide_mail' ],
|
b3ef6f91
Yarik
test
|
228
229
|
'default',
'value' => 0,
|
76f36646
Yarik
test
|
230
231
232
233
234
235
236
237
238
239
|
],
[
[
'social_vk',
'social_t',
'social_in',
'social_fb',
],
'filter',
'filter' => function($value) {
|
78ab7436
Yarik
test
|
240
|
if(empty( $value )) {
|
5d627502
Yarik
test
|
241
242
|
return $value;
}
|
76f36646
Yarik
test
|
243
244
245
246
247
248
|
if(!preg_match('/^https?:\/{2}.*$/', $value)) {
$value = 'https://' . $value;
}
return $value;
},
],
|
e8236f44
Yarik
test
|
249
250
251
252
253
254
255
256
257
258
259
260
261
|
];
}
public function getBusyText()
{
return $this->busy ? 'Занят' : 'Свободный';
}
public function getLastVisit()
{
return \Yii::$app->formatter->asRelativeTime(new \DateTime($this->date_visit));
}
|
76f36646
Yarik
test
|
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
public function getLastVisitCabinet()
{
$time = strtotime($this->date_visit);
$date = date('d.m.Y', $time);
if($date == date('d.m.Y')) {
return 'Сегодня';
} elseif($date == date('d.m.Y', time() - 24 * 3600)) {
return 'Вчера';
} elseif($date == date('d.m.Y', time() - 48 * 3600)) {
return '2 дня назад';
} else {
return date('d.m.Y', $time);
}
}
|
e8236f44
Yarik
test
|
277
278
279
280
281
282
|
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
|
06ec2844
Administrator
28.03.16
|
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
|
'user_id' => Yii::t('app', 'user_id'),
'view_count' => Yii::t('app', 'view_count'),
'busy' => Yii::t('app', 'busy'),
'date_visit' => Yii::t('app', 'date_visit'),
'experience' => Yii::t('app', 'experience'),
'rank' => Yii::t('app', 'rank'),
'salary' => Yii::t('app', 'salary'),
'job' => Yii::t('app', 'job'),
'location' => Yii::t('app', 'location'),
'soft' => Yii::t('app', 'soft'),
'user_info_id' => Yii::t('app', 'user_info_id'),
'guarantee' => Yii::t('app', 'guarantee'),
'contract' => Yii::t('app', 'contract'),
'estimate' => Yii::t('app', 'estimate'),
'purchase' => Yii::t('app', 'purchase'),
'delivery' => Yii::t('app', 'delivery'),
'prepayment' => Yii::t('app', 'prepayment'),
'about' => Yii::t('app', 'about'),
'type' => Yii::t('app', 'type'),
'member' => Yii::t('app', 'member'),
'alt_location' => Yii::t('app', 'alt_location'),
'country' => Yii::t('app', 'country'),
'city' => Yii::t('app', 'city'),
'image' => Yii::t('app', 'image_ui'),
'poster' => Yii::t('app', 'poster'),
'social_vk' => Yii::t('app', 'social_vk'),
'social_fb' => Yii::t('app', 'social_fb'),
'social_in' => Yii::t('app', 'social_in'),
'social_t' => Yii::t('app', 'social_t'),
'geography' => Yii::t('app', 'geography'),
'geographies' => Yii::t('app', 'geographies'),
'salary_currency' => Yii::t('app', 'salary_currency'),
|
9cc08528
Yarik
test
|
315
316
|
'is_customer' => '',
'is_freelancer' => '',
|
06ec2844
Administrator
28.03.16
|
317
|
'hide_mail' => Yii::t('app', 'hide_mail'),
|
e8236f44
Yarik
test
|
318
319
320
|
];
}
|
d02fd466
Yarik
test
|
321
|
|
76f36646
Yarik
test
|
322
323
|
public function getUser()
{
|
eb7e82fb
Administrator
29.02.16
|
324
325
326
|
return $this->hasOne(User::className(), [ 'id' => 'user_id' ]);
}
|
d02fd466
Yarik
test
|
327
328
329
330
331
332
|
public function beforeSave($insert)
{
$this->geography = json_encode($this->geographies, JSON_UNESCAPED_UNICODE);
return parent::beforeSave($insert);
}
|
76f36646
Yarik
test
|
333
334
|
public function getName()
{
|
6674bbe8
Administrator
29.02.16
|
335
|
return $this->user->name;
|
3dc20ff7
Administrator
24.02.16
|
336
337
|
}
|
d02fd466
Yarik
test
|
338
339
340
341
342
|
public function getGeographies()
{
return json_decode($this->geography);
}
|
eb7e82fb
Administrator
29.02.16
|
343
344
345
346
347
|
public function getGeographyString()
{
return implode(',', json_decode($this->geography));
}
|
d02fd466
Yarik
test
|
348
349
350
351
|
public function setGeographies($value)
{
$this->geographies = $value;
}
|
420d3dcd
Yarik
test
|
352
|
|
38a6e1dd
Yarik
test
|
353
354
|
public function getCurrency()
{
|
76f36646
Yarik
test
|
355
|
return $this->hasOne(Currency::className(), [ 'currency_id' => 'salary_currency' ]);
|
38a6e1dd
Yarik
test
|
356
357
|
}
|
1face72c
Yarik
test
|
358
|
}
|