From b99eca2003c9826214c8b2df91a2fc9eacb571ed Mon Sep 17 00:00:00 2001 From: Kei Date: Fri, 21 Jun 2024 01:08:39 +0700 Subject: [PATCH] Update UrlHubLinkChecker.php --- app/Http/Middleware/UrlHubLinkChecker.php | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/app/Http/Middleware/UrlHubLinkChecker.php b/app/Http/Middleware/UrlHubLinkChecker.php index 2849c6d25..a8354362a 100644 --- a/app/Http/Middleware/UrlHubLinkChecker.php +++ b/app/Http/Middleware/UrlHubLinkChecker.php @@ -14,7 +14,10 @@ class UrlHubLinkChecker */ public function handle(Request $request, \Closure $next) { - if ($this->canGenerateUniqueRandomKeys() == false) { + // Ensure that unique random keys can be generated by checking the remaining + // capacity of the key generator service. If the capacity is zero, it indicates + // that no more unique keys can be generated. + if (app(KeyGeneratorService::class)->remainingCapacity() === 0) { return redirect()->back() ->withFlashError( __('Sorry, our service is currently under maintenance.') @@ -23,20 +26,4 @@ public function handle(Request $request, \Closure $next) return $next($request); } - - /** - * Ensures that unique random keys can be generated. - * - * Karena kata kunci yang dihasilkan harus unik, maka kita perlu memastikan - * bahwa kata kunci unik yang ada apakah telah mencapai batas maksimum atau - * tidak. Ketika sudah mencapai batas maksimum, ini perlu dihentikan. - */ - private function canGenerateUniqueRandomKeys(): bool - { - if (app(KeyGeneratorService::class)->remainingCapacity() === 0) { - return false; - } - - return true; - } }