plugin management + user tables and torrents table text column migrate

This commit is contained in:
xiaomlove
2025-01-19 14:37:00 +08:00
parent 0f88ab8d82
commit 403a9447a9
66 changed files with 1432 additions and 786 deletions

View File

@@ -182,9 +182,9 @@ class User extends Authenticatable implements FilamentUser, HasName
* @var array
*/
protected $fillable = [
'username', 'email', 'passhash', 'secret', 'stylesheet', 'editsecret', 'added', 'modcomment', 'enabled', 'status',
'username', 'email', 'passhash', 'secret', 'stylesheet', 'editsecret', 'added', 'enabled', 'status',
'leechwarn', 'leechwarnuntil', 'page', 'class', 'uploaded', 'downloaded', 'clientselect', 'showclienterror', 'last_home',
'seedbonus', 'bonuscomment', 'downloadpos', 'vip_added', 'vip_until', 'title', 'invites', 'attendance_card',
'seedbonus', 'downloadpos', 'vip_added', 'vip_until', 'title', 'invites', 'attendance_card',
'seed_points_per_hour', 'passkey',
];
@@ -229,7 +229,7 @@ class User extends Authenticatable implements FilamentUser, HasName
'uploaded', 'downloaded', 'seedbonus', 'seedtime', 'leechtime',
'invited_by', 'enabled', 'seed_points', 'last_access', 'invites',
'lang', 'attendance_card', 'privacy', 'noad', 'downloadpos', 'donoruntil', 'donor',
'bonuscomment', 'downloadpos', 'vip_added', 'vip_until', 'title', 'invites', 'attendance_card',
'downloadpos', 'vip_added', 'vip_until', 'title', 'invites', 'attendance_card',
'seed_points_per_hour'
];
@@ -535,6 +535,11 @@ class User extends Authenticatable implements FilamentUser, HasName
return $this->examAndTasks()->wherePivot("status", ExamUser::STATUS_NORMAL);
}
public function modifyLogs(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(UserModifyLog::class, "user_id");
}
public function getAvatarAttribute($value)
{
if ($value) {
@@ -560,10 +565,17 @@ class User extends Authenticatable implements FilamentUser, HasName
throw new \RuntimeException('This method only works when user exists !');
}
//@todo how to do prepare bindings here ?
$comment = addslashes($comment);
do_log("update: " . json_encode($update) . ", $commentField: $comment", 'notice');
$update[$commentField] = NexusDB::raw("if($commentField = '', '$comment', concat_ws('\n', '$comment', $commentField))");
return $this->update($update);
// $comment = addslashes($comment);
// do_log("update: " . json_encode($update) . ", $commentField: $comment", 'notice');
// $update[$commentField] = NexusDB::raw("if($commentField = '', '$comment', concat_ws('\n', '$comment', $commentField))");
if ($commentField != "modcomment") {
throw new \RuntimeException("unsupported commentField: $commentField !");
}
return NexusDB::transaction(function () use ($update, $comment) {
$this->modifyLogs()->create(['content' => $comment]);
return $this->update($update);
});
}
public function canAccessAdmin(): bool