mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-13 03:43:45 +02:00
admin(ui): display dynamic user information on sidebar
This commit is contained in:
@@ -168,9 +168,13 @@ class User extends Model implements
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toVueObject(): array
|
||||
public function toReactObject(): array
|
||||
{
|
||||
return (new Collection($this->toArray()))->except(['id', 'external_id'])->toArray();
|
||||
$object = (new Collection($this->toArray()))->except(['id', 'external_id'])->toArray();
|
||||
$object['avatar_url'] = $this->avatarURL();
|
||||
$object['role_name'] = $this->roleName();
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -203,6 +207,26 @@ class User extends Model implements
|
||||
return trim($this->name_first . ' ' . $this->name_last);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get's the avatar url for the user.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function avatarURL(): string
|
||||
{
|
||||
return 'https://www.gravatar.com/avatar/' . md5($this->email) . '.jpg';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get's the name of the role assigned to a user.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function roleName():? string
|
||||
{
|
||||
return $this->root_admin ? 'Super Administrator' : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all servers that a user owns.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user