Добавлен функционал очистки устаревших MinecraftAccessKey

This commit is contained in:
ErickSkrauch
2017-09-27 19:52:28 +03:00
parent d114424906
commit ec0b25e88d
4 changed files with 34 additions and 6 deletions

View File

@@ -31,11 +31,11 @@ class MinecraftAccessKey extends ActiveRecord {
const LIFETIME = 172800; // Ключ актуален в течение 2 дней
public static function tableName() {
public static function tableName(): string {
return '{{%minecraft_access_keys}}';
}
public function behaviors() {
public function behaviors(): array {
return [
[
'class' => TimestampBehavior::class,
@@ -49,11 +49,11 @@ class MinecraftAccessKey extends ActiveRecord {
];
}
public function getAccount() : ActiveQuery {
public function getAccount(): ActiveQuery {
return $this->hasOne(Account::class, ['id' => 'account_id']);
}
public function isExpired() : bool {
public function isExpired(): bool {
return time() > $this->updated_at + self::LIFETIME;
}