Blame view

common/models/UserInfo.php 9.22 KB
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
1face72c   Yarik   test
32
       */
e8236f44   Yarik   test
33
      class UserInfo extends \yii\db\ActiveRecord
1face72c   Yarik   test
34
      {
8f939a27   Administrator   add Vitaliy's wid...
35
  
e8236f44   Yarik   test
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
62
63
64
65
66
67
68
          // Константа обознащающая физическое лицо
          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';
          }
  
          /**
           * @inheritdoc
           */
          public function rules()
          {
              return [
                  [
3e86d3d1   Yarik   test
69
70
71
72
73
74
                      [
                          'city',
                      ],
                      'required',
                  ],
                  [
e8236f44   Yarik   test
75
                      [
e8236f44   Yarik   test
76
77
                          'is_customer',
                          'is_freelancer',
9cc08528   Yarik   test
78
                          'salary_currency',
e8236f44   Yarik   test
79
80
81
82
                      ],
                      'integer',
                  ],
                  [
d02fd466   Yarik   test
83
84
85
86
                      [
                          'date_visit',
                          'geographies',
                      ],
e8236f44   Yarik   test
87
88
89
90
91
                      'safe',
                  ],
                  [
                      [
                          'soft',
e8236f44   Yarik   test
92
93
94
95
96
                          'about',
                          'city',
                          'country',
                          'image',
                          'poster',
e8236f44   Yarik   test
97
98
99
100
101
102
                      ],
                      'string',
                  ],
                  [
                      [ 'prepayment' ],
                      'number',
9d05331a   Yarik   test
103
                      'min' => 0,
d02fd466   Yarik   test
104
                      'max' => 100,
e8236f44   Yarik   test
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
                  ],
                  [
                      [ 'experience' ],
                      'integer',
                      'max' => date('Y'),
                      'min' => 1950,
                  ],
                  [
                      [ 'experience' ],
                      'default',
                      'value' => date('Y'),
                  ],
                  [
                      [
                          'rank',
                          'location',
                      ],
                      'string',
                      'max' => 50,
                  ],
                  [
                      [
e8236f44   Yarik   test
127
128
129
130
131
132
133
134
135
                          'job',
                      ],
                      'string',
                      'max' => 255,
                  ],
                  [
                      [
                          'busy',
                          'member',
f1f3595c   Yarik   test
136
137
138
139
                          'contract',
                          'estimate',
                          'purchase',
                          'delivery',
e8236f44   Yarik   test
140
141
142
143
                      ],
                      'boolean',
                  ],
                  [
d02fd466   Yarik   test
144
145
146
147
148
149
150
151
                      [
                          'view_count',
                          'busy',
                          'member',
                          'salary',
                          'guarantee',
                          'prepayment',
                      ],
e8236f44   Yarik   test
152
153
154
                      'default',
                      'value' => 0,
                  ],
f1f3595c   Yarik   test
155
                  [
d02fd466   Yarik   test
156
157
158
159
                      [
                          'salary',
                          'guarantee',
                      ],
f1f3595c   Yarik   test
160
161
162
                      'integer',
                      'min' => 0,
                  ],
5346fcf9   Yarik   test
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
                  [
                      [
                          '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
191
192
193
194
195
196
197
                  [
                      [
                          'geographies',
                      ],
                      'default',
                      'value' => [],
                  ],
e8236f44   Yarik   test
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
              ];
          }
  
          public function getBusyText()
          {
              return $this->busy ? 'Занят' : 'Свободный';
          }
  
          public function getLastVisit()
          {
              return \Yii::$app->formatter->asRelativeTime(new \DateTime($this->date_visit));
          }
  
          /**
           * @inheritdoc
           */
          public function attributeLabels()
          {
              return [
9cc08528   Yarik   test
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
                  'user_id'         => Yii::t('app', 'User ID'),
                  'view_count'      => Yii::t('app', 'Количество просмотров'),
                  'busy'            => Yii::t('app', 'Статус'),
                  'date_visit'      => Yii::t('app', 'Дата визита'),
                  'experience'      => Yii::t('app', 'Опыт работы'),
                  'rank'            => Yii::t('app', 'Rank'),
                  'salary'          => Yii::t('app', 'Зарплата'),
                  'job'             => Yii::t('app', 'Место работы'),
                  'location'        => Yii::t('app', 'Место расположения'),
                  'soft'            => Yii::t('app', 'Работа с программами'),
                  'user_info_id'    => Yii::t('app', 'User Info ID'),
                  'guarantee'       => Yii::t('app', 'Гарантия качества работ'),
                  'contract'        => Yii::t('app', 'Работа по договору'),
                  'estimate'        => Yii::t('app', 'Предоставляете смету'),
                  'purchase'        => Yii::t('app', 'Делаете сами закупку материалов'),
                  'delivery'        => Yii::t('app', 'Занимаетесь сами доставкой материалов'),
                  'prepayment'      => Yii::t('app', 'Минимальная предоплата за работы'),
                  'about'           => Yii::t('app', 'О себе'),
                  'type'            => Yii::t('app', 'Is Default'),
                  'member'          => Yii::t('app', 'Членство в МФП'),
                  'alt_location'    => 'Город не в списке',
                  'country'         => Yii::t('app', 'Страна'),
                  'city'            => Yii::t('app', 'Город'),
                  'image'           => Yii::t('app', 'Аватар'),
                  'poster'          => Yii::t('app', 'Подложка'),
                  'social_vk'       => Yii::t('app', 'Vk.com'),
                  'social_fb'       => Yii::t('app', 'FaceBook.com'),
                  'social_in'       => Yii::t('app', 'LinkedIn.com'),
                  'social_t'        => Yii::t('app', 'Twitter.com'),
                  'geography'       => Yii::t('app', 'География работ'),
                  'geographies'     => Yii::t('app', 'География работ'),
                  'salary_currency' => Yii::t('app', 'Валюта'),
                  'is_customer'     => '',
                  'is_freelancer'   => '',
e8236f44   Yarik   test
251
252
253
  
              ];
          }
d02fd466   Yarik   test
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
  
          public function beforeSave($insert)
          {
              $this->geography = json_encode($this->geographies, JSON_UNESCAPED_UNICODE);
              return parent::beforeSave($insert);
          }
  
          public function getGeographies()
          {
              return json_decode($this->geography);
          }
  
          public function setGeographies($value)
          {
              $this->geographies = $value;
          }
1face72c   Yarik   test
270
      }