mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 20:40:49 +08:00
[admin] add username change log
This commit is contained in:
@@ -4,13 +4,35 @@ namespace App\Models;
|
||||
|
||||
class UsernameChangeLog extends NexusModel
|
||||
{
|
||||
protected $fillable = ['uid', 'username_old', 'username_new', ];
|
||||
protected $fillable = ['uid', 'username_old', 'username_new', 'operator', 'change_type'];
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
const CHANGE_TYPE_USER = 1;
|
||||
const CHANGE_TYPE_ADMIN = 2;
|
||||
|
||||
public static array $changeTypes = [
|
||||
self::CHANGE_TYPE_USER => ['text' => 'User'],
|
||||
self::CHANGE_TYPE_ADMIN => ['text' => 'Administrator'],
|
||||
];
|
||||
|
||||
public function getChangeTypeTextAttribute()
|
||||
{
|
||||
return nexus_trans('username-change-log.change_type.' . $this->change_type);
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'uid');
|
||||
}
|
||||
|
||||
public static function listChangeType()
|
||||
{
|
||||
$result = [];
|
||||
foreach (self::$changeTypes as $type => $info) {
|
||||
$result[$type] = nexus_trans('username-change-log.change_type.' . $type);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user