'common\behaviors\ShowImage', ], ]; } /** * @inheritdoc */ public function rules() { return [ [ [ 'email', ], 'required', ], [ [ 'is_customer', 'is_freelancer', 'salary_currency', ], 'integer', ], [ [ 'date_visit', 'geographies', ], 'safe', ], [ [ 'soft', 'about', 'city', 'country', 'image', 'poster', ], 'string', ], [ [ 'prepayment' ], 'number', 'min' => 0, 'max' => 100, ], [ [ 'experience' ], 'integer', 'max' => date('Y'), 'min' => 1950, ], [ [ 'experience' ], 'default', 'value' => date('Y'), ], [ [ 'rank', 'location', ], 'string', 'max' => 50, ], [ [ 'job', ], 'string', 'max' => 255, ], [ [ 'busy', 'member', 'contract', 'estimate', 'purchase', 'delivery', ], 'boolean', ], [ [ 'view_count', 'busy', 'member', 'salary', 'guarantee', 'prepayment', ], 'default', 'value' => 0, ], [ [ 'salary', 'guarantee', ], 'integer', 'min' => 0, ], [ [ '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]+\/?$/', ], [ [ 'geographies', ], 'default', 'value' => [], ], [ [ 'email', ], 'email', ], [ [ 'hide_mail' ], 'integer', 'min' => 0, 'max' => 1, ], [ ['hide_mail'], 'default', 'value' => 0, ] ]; } public function getBusyText() { return $this->busy ? 'Занят' : 'Свободный'; } public function getLastVisit() { return \Yii::$app->formatter->asRelativeTime(new \DateTime($this->date_visit)); } /** * @inheritdoc */ public function attributeLabels() { return [ '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' => '', 'hide_mail' => Yii::t('app', 'не публиковать Email'), ]; } public function getUser(){ return $this->hasOne(User::className(), [ 'id' => 'user_id' ]); } public function beforeSave($insert) { $this->geography = json_encode($this->geographies, JSON_UNESCAPED_UNICODE); return parent::beforeSave($insert); } public function getName(){ return $this->user->name; } public function getGeographies() { return json_decode($this->geography); } public function getGeographyString() { return implode(',', json_decode($this->geography)); } public function setGeographies($value) { $this->geographies = $value; } }