[admin] add grant props

This commit is contained in:
xiaomlove
2022-08-11 17:12:36 +08:00
parent 72908e38f4
commit 9332b676b4
18 changed files with 156 additions and 18 deletions
+9
View File
@@ -42,4 +42,13 @@ class NexusModel extends Model
return $d && $d->format($format) === $date;
}
public function getDeadlineText($field = 'deadline')
{
$raw = $this->getRawOriginal($field);
if (in_array($raw, [null, '0000-00-00 00:00:00', ''], true)) {
return nexus_trans("label.permanent");
}
return sprintf('%s: %s', nexus_trans('label.deadline'), $raw);
}
}
-1
View File
@@ -503,5 +503,4 @@ class User extends Authenticatable implements FilamentUser, HasName
}
}
+13 -1
View File
@@ -10,7 +10,6 @@ class UserMeta extends NexusModel
const STATUS_NORMAL = 0;
const META_KEY_PERSONALIZED_USERNAME = 'PERSONALIZED_USERNAME';
const META_KEY_CHANGE_USERNAME = 'CHANGE_USERNAME';
@@ -21,6 +20,19 @@ class UserMeta extends NexusModel
'deadline' => 'datetime',
];
public static array $metaKeys = [
self::META_KEY_PERSONALIZED_USERNAME => ['text' => 'PERSONALIZED_USERNAME', 'multiple' => false],
self::META_KEY_CHANGE_USERNAME => ['text' => 'CHANGE_USERNAME', 'multiple' => false],
];
public static function listProps()
{
return [
self::META_KEY_PERSONALIZED_USERNAME => nexus_trans('label.user_meta.meta_keys.' . self::META_KEY_PERSONALIZED_USERNAME),
self::META_KEY_CHANGE_USERNAME => nexus_trans('label.user_meta.meta_keys.' . self::META_KEY_CHANGE_USERNAME),
];
}
public function getMetaKeyTextAttribute()
{
return nexus_trans('label.user_meta.meta_keys.' . $this->meta_key) ?? '';