TimestampBehavior::className(), 'createdAtAttribute' => 'created_at', 'updatedAtAttribute' => 'updated_at', //'value' => new Expression('NOW()'), 'value' => function() { return time();}, ], ]; } /** * getUidByApiToken * @param $token * @return bool */ public static function getUidByApiToken($token) { $uid = static::find()->select('user_id') ->where(['access_token' => $token]) ->andWhere(['>', 'expires', time()]) ->scalar(); return $uid != null && is_numeric($uid) ? $uid : null; } }