increments('id')->comment('用户ID'); $table->string('username', 20)->nullable()->unique()->comment('用户名(微信注册用户可为空)'); $table->string('password', 100)->nullable()->comment('密码(微信注册用户可为空)'); $table->string('nickname', 20)->default('')->comment('昵称'); $table->string('email', 50)->default('')->comment('邮箱'); $table->timestamp('email_verified_at')->nullable(); // 小程序用户扩展字段(微信授权登录,自动识别门店/供应商身份) $table->string('openid', 64)->nullable()->unique()->comment('微信OpenID(小程序用户唯一标识)'); $table->string('unionid', 64)->default('')->comment('微信UnionID'); $table->string('phone', 20)->default('')->comment('手机号(微信授权获取,用于匹配门店/供应商)'); $table->string('avatar', 255)->default('')->comment('头像'); $table->integer('type')->default(0)->comment('用户类型(0待绑定 1门店 2供应商)'); $table->integer('store_id')->default(0)->comment('关联门店ID(type=1时有效)'); $table->integer('supplier_id')->default(0)->comment('关联供应商ID(type=2时有效)'); $table->integer('status')->default(1)->comment('状态(1正常 0停用)'); $table->timestamp('last_login_at')->nullable()->comment('最后登录时间'); $table->rememberToken(); $table->timestamps(); $table->index(['type', 'store_id'], 'user_type_store_index'); $table->comment('APP用户表(含小程序用户)'); }); } } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('user'); } };