设置项目编号

admin6个月前Laravel125
$max = Db::table('member')->max('id') ?? 0; 
if ($max < 100000) {
    $cd = $this->createNonceStr(6 - strlen($max));
    $max = str_pad($max, 6, $cd, STR_PAD_LEFT);

}



public function createNonceStr($length = 16)
{
    $chars = '0123456789';
    $str = ''; for ($i = 0; $i < $length; $i++) {
        $str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
    } return $str;
}

相关文章

PHP 严格类型

只需在 PHP 代码文件的开头加上declare(strict_types = 1);这一行魔法代码,就能开启严格类型检查之旅。...

获取微信的Token

 public function Token()    {        $this->path = __DIR__ . &...

php 优化

使用 gc_collect_cycles() 强制进行垃圾回收 PHP 的垃圾回收机制会自动释放不再使用的变量所占用的内存。然而,在某些情况下,尤其是在长时间运行的脚本(如 CLI...

修改密码

/** * 修改密码 */publicfunction setpass(){    $type = request()->input('type');// 1...

用户注册账号

public function register(){    $mobile = request()->input('mobile');   &nb...

生成二维码

public function qrcode($uid){    require_once base_path() . '/public/phpqrcode/phpqrco...