Skip to content

Commit

Permalink
Update UrlHubLinkChecker.php
Browse files Browse the repository at this point in the history
  • Loading branch information
realodix committed Jun 20, 2024
1 parent 003c558 commit b99eca2
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions app/Http/Middleware/UrlHubLinkChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand All @@ -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;
}
}

0 comments on commit b99eca2

Please sign in to comment.