Files
nexusphp/app/Models/UserMeta.php
T

35 lines
796 B
PHP
Raw Normal View History

2022-08-10 17:38:05 +08:00
<?php
namespace App\Models;
class UserMeta extends NexusModel
{
protected $fillable = ['uid', 'meta_key', 'meta_value', 'status', 'deadline'];
public $timestamps = true;
const STATUS_NORMAL = 0;
const META_KEY_PERSONALIZED_USERNAME = 'PERSONALIZED_USERNAME';
const META_KEY_CHANGE_USERNAME = 'CHANGE_USERNAME';
protected $appends = ['meta_key_text'];
2022-08-11 13:48:26 +08:00
protected $casts = [
'deadline' => 'datetime',
];
2022-08-10 17:38:05 +08:00
public function getMetaKeyTextAttribute()
{
return nexus_trans('label.user_meta.meta_keys.' . $this->meta_key) ?? '';
}
2022-08-11 13:48:26 +08:00
public function isValid(): bool
2022-08-10 17:38:05 +08:00
{
2022-08-11 13:48:26 +08:00
return $this->status == self::STATUS_NORMAL && ($this->getRawOriginal('deadline') === null || ($this->deadline && $this->deadline->gte(now())));
2022-08-10 17:38:05 +08:00
}
}