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

