设置项目编号

admin1年前Laravel347
$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;
}

相关文章

用户注册账号

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

不重复 的推荐码

public function getcode(){    do {        $code = rand(10000000, 99999...

微信支付V3

 public static function pay($order_sn = '11111', $money = '12', $uid = 7) ...

生成唯一的订单号

public function get_order_sn() {     return date('Ymd') ...

抖音小程序码

public function dyqrcode($uid){    $url = "https://open.douyin.com/api/apps/v1/qrcode...

验证手机号

public function phone($phone){    $pat = '/'        . '^13...