Skip to content

Commit

Permalink
Update KeyGenerator.php
Browse files Browse the repository at this point in the history
  • Loading branch information
stevebauman committed Jul 23, 2024
1 parent 6198d0c commit ff7c8cb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Classes/KeyGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ public function __construct(Hashids $hashids)
*/
public function generateRandom(): string
{
$ID = $this->getLastInsertedID();

do {
$key = $this->hashids->encodeHex($this->getLastInsertedID().uniqid());
$ID++;
$key = $this->hashids->encodeHex($ID.uniqid());
} while (ShortURL::where('url_key', $key)->exists());

return $key;
Expand Down

0 comments on commit ff7c8cb

Please sign in to comment.