TimestampBehavior::class, 'createdAtAttribute' => 'created_at', 'updatedAtAttribute' => 'updated_at', 'value' => new Expression('NOW()'), ], ]; } /** * {@inheritdoc} */ public static function tableName() { return 'user_card'; } /** * {@inheritdoc} */ public function rules() { return [ [['fio', 'status'], 'required'], [['status'], 'integer'], [['gender'], 'in', 'range' => array_keys($this->genders)], [['dob', 'created_at', 'updated_at'], 'safe'], [['fio', 'passport', 'photo', 'email', 'resume'], 'string', 'max' => 255], [['status'], 'exist', 'skipOnError' => true, 'targetClass' => Status::class, 'targetAttribute' => ['status' => 'id']], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'fio' => 'ФИО', 'passport' => 'Паспорт', 'photo' => 'Фото', 'email' => 'Email', 'gender' => 'Пол', 'dob' => 'Дата рождения', 'status' => 'Статус', 'created_at' => 'Дата создания', 'updated_at' => 'Дата редактирование', 'resume' => 'Резюме', ]; } /** * @return \yii\db\ActiveQuery */ public function getStatus0() { return $this->hasOne(Status::class, ['id' => 'status']); } public function getGenders() { return [ self::GENDER_M => 'Мужчина', self::GENDER_W => 'Женщина' ]; } /** * @return string status text label */ public function getGendersText() { return $this->genders[$this->gender]; } }