From 2b56de2a017790d4a97e98852f8205dc9c8f8aea Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Tue, 13 Jun 2023 01:53:58 +0800 Subject: [PATCH] merge pr --- app/Console/Commands/Test.php | 3 +-- app/Repositories/MedalRepository.php | 6 ++++++ include/constants.php | 2 +- public/modtask.php | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index 85376d50..0b2eae14 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -97,8 +97,7 @@ class Test extends Command */ public function handle() { - $r = TorrentUpdated::dispatch(5); - dd($r); + } } diff --git a/app/Repositories/MedalRepository.php b/app/Repositories/MedalRepository.php index 3e53f040..85f1cca7 100644 --- a/app/Repositories/MedalRepository.php +++ b/app/Repositories/MedalRepository.php @@ -84,6 +84,12 @@ class MedalRepository extends BaseRepository } $current = $userMedal->status; if ($current == UserMedal::STATUS_NOT_WEARING) { + $maxWearAllow = Setting::get('system.maximum_number_of_medals_can_be_worn'); + $user = User::query()->findOrFail($userId, User::$commonFields); + $wearCount = $user->wearing_medals()->count(); + if ($maxWearAllow && $wearCount >= $maxWearAllow) { + throw new NexusException(nexus_trans('medal.max_allow_wearing', ['count' => $maxWearAllow])); + } $userMedal->status = UserMedal::STATUS_WEARING; } elseif ($current == UserMedal::STATUS_WEARING) { $userMedal->status = UserMedal::STATUS_NOT_WEARING; diff --git a/include/constants.php b/include/constants.php index 9a312537..6eaa4182 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@