mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 20:17:24 +08:00
normalize HitAndRun::getIsEnabled()
This commit is contained in:
@@ -57,7 +57,8 @@ class HitAndRun extends NexusModel
|
|||||||
|
|
||||||
public static function getIsEnabled(): bool
|
public static function getIsEnabled(): bool
|
||||||
{
|
{
|
||||||
return Setting::get('hr.mode') != self::MODE_DISABLED;
|
$result = Setting::get('hr.mode');
|
||||||
|
return $result && in_array($result, [self::MODE_GLOBAL, self::MODE_MANUAL]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function torrent(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
public function torrent(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ class BonusRepository extends BaseRepository
|
|||||||
{
|
{
|
||||||
public function consumeToCancelHitAndRun($uid, $hitAndRunId)
|
public function consumeToCancelHitAndRun($uid, $hitAndRunId)
|
||||||
{
|
{
|
||||||
$hitAndRunMode = Setting::get('hr.mode');
|
if (!HitAndRun::getIsEnabled()) {
|
||||||
if ($hitAndRunMode == HitAndRun::MODE_DISABLED) {
|
|
||||||
throw new \LogicException("H&R not enabled.");
|
throw new \LogicException("H&R not enabled.");
|
||||||
}
|
}
|
||||||
$user = User::query()->findOrFail($uid);
|
$user = User::query()->findOrFail($uid);
|
||||||
@@ -44,6 +43,7 @@ class BonusRepository extends BaseRepository
|
|||||||
'now' => Carbon::now()->toDateTimeString(),
|
'now' => Carbon::now()->toDateTimeString(),
|
||||||
'bonus' => $requireBonus,
|
'bonus' => $requireBonus,
|
||||||
], $user->locale);
|
], $user->locale);
|
||||||
|
$comment = addslashes($comment);
|
||||||
do_log("comment: $comment");
|
do_log("comment: $comment");
|
||||||
$hitAndRun->update([
|
$hitAndRun->update([
|
||||||
'status' => HitAndRun::STATUS_PARDONED,
|
'status' => HitAndRun::STATUS_PARDONED,
|
||||||
|
|||||||
Reference in New Issue
Block a user