no message

This commit is contained in:
hajimi
2026-06-11 12:15:29 +08:00
parent 10ebe39c30
commit 96efa1d905
5859 changed files with 815501 additions and 5 deletions
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace app\common\model;
class ShortLink extends BaseModel
{
protected $name = 'short_link';
/**
* @notes 生成唯一随机码
*/
public static function generateCode(int $length = 8): string
{
$chars = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789';
do {
$code = '';
for ($i = 0; $i < $length; $i++) {
$code .= $chars[random_int(0, strlen($chars) - 1)];
}
} while (self::where('code', $code)->findOrEmpty()->isExists());
return $code;
}
}