Schema::create(‘users‘, function (Blueprint $table) {
$table->bigIncrements(‘id‘);
$table->unsignedBigInteger(‘role_id‘)->default(0)->comment(‘角色id‘);
$table->string(‘username‘, 20)->comment(‘用户名‘);
$table->string(‘truename‘, 50)->default(‘未知‘)->comment(‘真实姓名‘);
$table->string(‘password‘, 255)->comment(‘密码‘);
$table->string(‘email‘, 50)->nullable()->comment(‘邮箱‘);
$table->string(‘phone‘, 15)->default()->comment(‘手机号码‘);
$table->enum(‘sex‘,[‘先生‘,‘女士‘])->default(‘先生‘)->comment(‘性别‘);
$table->char(‘last_ip‘,15)->default(‘‘)->comment(‘登录ip地址‘);
$table->timestamps();
// 软删除
$table->softDeletes();
});
Schema::create(‘roles‘, function (Blueprint $table) {
$table->bigIncrements(‘id‘);
$table->string(‘rolename‘,20)->comment(‘角色名称‘);
$table->timestamps();
// 软删除
$table->softDeletes();
});
Schema::create(‘permissions‘, function (Blueprint $table) {
$table->bigIncrements(‘id‘);
$table->string(‘PermissionName‘, 50)->comment(‘权限名称‘);
$table->string(‘route_name‘, 100)->default(‘‘)->comment(‘路由别名,权限认证标识‘);
$table->unsignedBigInteger(‘pid‘)->default(0)->comment(‘上级ID‘);
$table->enum(‘is_menu‘, [‘0‘, ‘1‘])->default(‘0‘)->comment(‘是否为菜单,0否,1是‘);
$table->timestamps();
$table->softDeletes();
});
Schema::create(‘role_permission‘,function(Blueprint $table){
// 角色ID
$table->unsignedBigInteger(‘role_id‘)->default(0)->comment(‘角色ID‘);
// 权限ID
$table->unsignedBigInteger(‘permission_id‘)->default(0)->comment(‘权限ID‘);
});
原文:https://www.cnblogs.com/zqblog1314/p/13344346.html