support modify personal attendance card

This commit is contained in:
xiaomlove
2022-05-29 15:19:16 +08:00
parent cf7f2af06e
commit 36a1f83d7d
40 changed files with 289 additions and 48 deletions

View File

@@ -26,6 +26,7 @@ class UserResource extends JsonResource
'class_text' => $this->class_text,
'avatar' => $this->avatar,
'invites' => $this->invites,
'attendance_card' => $this->attendance_card,
'uploaded' => $this->uploaded,
'uploaded_text' => mksize($this->uploaded),
'downloaded' => $this->downloaded,

View File

@@ -155,7 +155,7 @@ class User extends Authenticatable
'id', 'username', 'email', 'class', 'status', 'added', 'avatar',
'uploaded', 'downloaded', 'seedbonus', 'seedtime', 'leechtime',
'invited_by', 'enabled', 'seed_points', 'last_access', 'invites',
'lang',
'lang', 'attendance_card',
];
public static function getDefaultUserAttributes(): array

View File

@@ -219,6 +219,7 @@ class UserRepository extends BaseRepository
'downloaded' => 'downloaded',
'bonus' => 'seedbonus',
'invites' => 'invites',
'attendance_card' => 'attendance_card',
];
if (!isset($fieldMap[$field])) {
throw new \InvalidArgumentException("Invalid field: $field, only support: " . implode(', ', array_keys($fieldMap)));
@@ -240,6 +241,9 @@ class UserRepository extends BaseRepository
} else {
throw new \InvalidArgumentException("Invalid action: $action.");
}
if ($new < 0) {
throw new NexusException("New value($new) lte 0");
}
//for administrator, use english
$modCommentText = nexus_trans('message.field_value_change_message_body', [
'field' => nexus_trans("user.labels.$sourceField", [], 'en'),