From 52c33658739a2b7762f3c037bc5f2ea0aeccb6b4 Mon Sep 17 00:00:00 2001 From: lgb <353856593@qq.com> Date: Wed, 24 Apr 2024 14:45:30 +0800 Subject: [PATCH] exam recurring add daily + TorrentDeleted event --- app/Events/TorrentDeleted.php | 38 +++++++++++++++++++++++++++++++++++ app/Models/Exam.php | 6 ++++++ include/constants.php | 2 +- resources/lang/en/exam.php | 1 + resources/lang/zh_CN/exam.php | 1 + resources/lang/zh_TW/exam.php | 1 + 6 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 app/Events/TorrentDeleted.php diff --git a/app/Events/TorrentDeleted.php b/app/Events/TorrentDeleted.php new file mode 100644 index 00000000..6fb539c4 --- /dev/null +++ b/app/Events/TorrentDeleted.php @@ -0,0 +1,38 @@ +torrentId = $torrentId; + } + + /** + * Get the channels the event should broadcast on. + * + * @return \Illuminate\Broadcasting\Channel|array + */ + public function broadcastOn() + { + return new PrivateChannel('channel-name'); + } +} diff --git a/app/Models/Exam.php b/app/Models/Exam.php index eaf36b49..c8e57b13 100644 --- a/app/Models/Exam.php +++ b/app/Models/Exam.php @@ -65,6 +65,7 @@ class Exam extends NexusModel self::FILTER_USER_REGISTER_DAYS_RANGE => ['name' => 'User register days range'], ]; + const RECURRING_DAILY = "Daily"; const RECURRING_WEEKLY = "Weekly"; const RECURRING_MONTHLY = "Monthly"; @@ -93,6 +94,7 @@ class Exam extends NexusModel public static function listRecurringOptions(): array { return [ + self::RECURRING_DAILY => nexus_trans("exam.recurring_daily"), self::RECURRING_WEEKLY => nexus_trans("exam.recurring_weekly"), self::RECURRING_MONTHLY => nexus_trans("exam.recurring_monthly"), ]; @@ -215,6 +217,8 @@ class Exam extends NexusModel return $time->startOfWeek(); } elseif ($recurring == self::RECURRING_MONTHLY) { return $time->startOfMonth(); + } elseif ($recurring == self::RECURRING_DAILY) { + return $time->startOfDay(); } throw new \RuntimeException("Invalid recurring: $recurring"); } @@ -226,6 +230,8 @@ class Exam extends NexusModel return $time->endOfWeek(); } elseif ($recurring == self::RECURRING_MONTHLY) { return $time->endOfMonth(); + } elseif ($recurring == self::RECURRING_DAILY) { + return $time->endOfDay(); } throw new \RuntimeException("Invalid recurring: $recurring"); } diff --git a/include/constants.php b/include/constants.php index 6dddd22c..e0857936 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ 'recurring', + 'recurring_daily' => 'once a day', 'recurring_weekly' => 'once a week', 'recurring_monthly' => 'once a month', 'recurring_help' => 'If specified as periodic, the appraisal start time is the start time of the current cycle, and the end time is the end time of the current cycle, which is said to be the natural week/month. At the end of each cycle, if the user still meets the screening criteria, the user will be automatically assigned to the next cycle.' , diff --git a/resources/lang/zh_CN/exam.php b/resources/lang/zh_CN/exam.php index 287a6937..cf10cb34 100644 --- a/resources/lang/zh_CN/exam.php +++ b/resources/lang/zh_CN/exam.php @@ -34,6 +34,7 @@ return [ ] ], 'recurring' => '周期性', + 'recurring_daily' => '每天一次', 'recurring_weekly' => '每周一次', 'recurring_monthly' => '每月一次', 'recurring_help' => '如果指定为周期性,考核开始时间为当前周期的开始时间,结束时间为当前周期的结束时间,这里说的都是自然周/月。每个周期结束后,如果用户仍然满足筛选条件,会自动为用户分配下个周期的任务。', diff --git a/resources/lang/zh_TW/exam.php b/resources/lang/zh_TW/exam.php index 806b36e4..5edfd152 100644 --- a/resources/lang/zh_TW/exam.php +++ b/resources/lang/zh_TW/exam.php @@ -34,6 +34,7 @@ return [ ] ], 'recurring' => '周期性', + 'recurring_daily' => '每天一次', 'recurring_weekly' => '每周一次', 'recurring_monthly' => '每月一次', 'recurring_help' => '如果指定為周期性,考核開始時間為當前周期的開始時間,結束時間為當前周期的結束時間,這裏說的都是自然周/月。每個周期結束後,如果用戶仍然滿足篩選條件,會自動為用戶分配下個周期的任務。',