Files
nexusphp/app/Models/UsernameChangeLog.php

39 lines
933 B
PHP
Raw Normal View History

2022-08-10 17:38:05 +08:00
<?php
namespace App\Models;
class UsernameChangeLog extends NexusModel
{
2022-08-10 23:38:10 +08:00
protected $fillable = ['uid', 'username_old', 'username_new', 'operator', 'change_type'];
2022-08-10 17:38:05 +08:00
public $timestamps = true;
2022-08-10 23:38:10 +08:00
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);
}
2022-08-10 17:38:05 +08:00
public function user()
{
return $this->belongsTo(User::class, 'uid');
}
2022-08-10 23:38:10 +08:00
public static function listChangeType()
{
$result = [];
foreach (self::$changeTypes as $type => $info) {
$result[$type] = nexus_trans('username-change-log.change_type.' . $type);
}
return $result;
}
2022-08-10 17:38:05 +08:00
}