yuyafeng

1. 关闭自增长并创建uuid字段(app/User.php)

public $incrementing = false;

public static function boot()
{
    parent::boot();
    static::creating(function ($model) {
        $model->{$model->getKeyName()} = (string)Str::uuid();  // use Illuminate\Support\Str;
    });
}

 

 

2. 将模型中的id字段改为uuid(database/migrations/2014_10_12_000000_create_users_table.php)

 

 

3. 刷新数据库

php artisan migrate:refresh

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2020-07-23
  • 2021-06-30
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-17
  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
  • 2021-10-26
相关资源
相似解决方案