255], [['token'], 'unique'], [['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'user_id' => 'User ID', 'token' => 'Token', 'created_at' => 'Created At', 'updated_at' => 'Updated At', 'expired_at' => 'Expired At', ]; } /** * @return ActiveQuery */ public function getUser() { return $this->hasOne(User::className(), ['id' => 'user_id']); } /** * @param string $tokenValue * @return bool */ public static function checkExistsByToken(string $tokenValue): bool { return self::find()->where(['token' => $tokenValue])->exists(); } }