show rainbow ID in userdetails page

This commit is contained in:
xiaomlove
2022-08-11 13:48:26 +08:00
parent 971f9b8509
commit 72908e38f4
4 changed files with 20 additions and 3 deletions
+6 -2
View File
@@ -17,14 +17,18 @@ class UserMeta extends NexusModel
protected $appends = ['meta_key_text'];
protected $casts = [
'deadline' => 'datetime',
];
public function getMetaKeyTextAttribute()
{
return nexus_trans('label.user_meta.meta_keys.' . $this->meta_key) ?? '';
}
public static function consumeBenefit($uid, $metaKey)
public function isValid(): bool
{
return $this->status == self::STATUS_NORMAL && ($this->getRawOriginal('deadline') === null || ($this->deadline && $this->deadline->gte(now())));
}
}
+1
View File
@@ -39,6 +39,7 @@ class AppServiceProvider extends ServiceProvider
Filament::registerNavigationGroups([
'User',
'Torrent',
'Other',
'System',
]);
});
+1 -1
View File
@@ -3736,7 +3736,7 @@ function get_username($id, $big = false, $link = true, $bold = true, $target = f
//medal
$medalHtml = '';
foreach ($arr['wearing_medals'] as $medal) {
$medalHtml .= sprintf('<img src="%s" title="%s" class="preview" style="vertical-align: sub;max-height: 16px;max-width: 16px;margin-left: 2pt"/>', $medal['image_large'], $medal['name']);
$medalHtml .= sprintf('<img src="%s" title="%s" class="preview" style="max-height: 16px;max-width: 16px;margin-left: 2pt"/>', $medal['image_large'], $medal['name']);
}
$href = getSchemeAndHttpHost() . "/userdetails.php?id=$id";
+12
View File
@@ -352,6 +352,18 @@ jQuery('#{$triggerId}').on("click", function () {
JS;
\Nexus\Nexus::js($consumeChangeUsernameJs, 'footer', false);
}
$metaKey = \App\Models\UserMeta::META_KEY_PERSONALIZED_USERNAME;
if ($metas->has($metaKey)) {
$rainbowID = $metas->get($metaKey)->first();
if ($rainbowID->isValid()) {
$props[] = sprintf(
'<div><strong>[%s]</strong>(%s: %s)</div>',
$rainbowID->metaKeyText, nexus_trans('label.deadline'), $rainbowID->deadline
);
}
}
if (!empty($props)) {
tr_small($lang_userdetails['row_user_props'], sprintf('<div style="display: inline">%s</div>', implode('&nbsp;|&nbsp;', $props)), 1);
}