This commit is contained in:
xiaomlove
2024-05-24 02:27:44 +08:00
parent 615bf19a3a
commit 2de8ffd9e0
8 changed files with 283 additions and 45 deletions
+2
View File
@@ -36,6 +36,8 @@ class BonusLogs extends NexusModel
const BUSINESS_TYPE_BUY_CHANGE_USERNAME_CARD = 17;
const BUSINESS_TYPE_GIFT_MEDAL = 18;
const BUSINESS_TYPE_BUY_TORRENT = 19;
const BUSINESS_TYPE_TASK_NOT_PASS_DEDUCT = 20;
const BUSINESS_TYPE_TASK_PASS_REWARD = 21;
const BUSINESS_TYPE_ROLE_WORK_SALARY = 1000;
const BUSINESS_TYPE_TORRENT_BE_DOWNLOADED = 1001;
+28
View File
@@ -254,4 +254,32 @@ class Exam extends NexusModel
throw new \RuntimeException("Invalid recurring: $recurring");
}
public function getMessageSubjectTransKey(string $result): string
{
return match ($this->type) {
self::TYPE_EXAM => "exam.checkout_{$result}_message_subject_for_exam",
self::TYPE_TASK => "exam.checkout_{$result}_message_subject_for_task",
default => throw new \RuntimeException("Invalid type: " . $this->type)
};
}
public function getMessageContentTransKey(string $result): string
{
return match ($this->type) {
self::TYPE_EXAM => "exam.checkout_{$result}_message_content_for_exam",
self::TYPE_TASK => "exam.checkout_{$result}_message_content_for_task",
default => throw new \RuntimeException("Invalid type: " . $this->type)
};
}
public function isTypeExam(): bool
{
return $this->type == self::TYPE_EXAM;
}
public function isTypeTask(): bool
{
return $this->type == self::TYPE_TASK;
}
}
+5
View File
@@ -514,6 +514,11 @@ class User extends Authenticatable implements FilamentUser, HasName
return $this->hasMany(UserPermission::class, 'uid');
}
public function examAndTasks(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
return $this->belongsToMany(Exam::class, "exam_users", "uid", "exam_id");
}
public function getAvatarAttribute($value)
{
if ($value) {