rbac 四张表
作者:互联网
创建节点资源控制器,并关联模型
php artisan make:controller Admin/NodeController -r -m Models/Node
角色表
roles表
$table->bigIncrements('id'); $table->string('name','20')->comment('角色名称'); $table->timestamps(); // 软删除 $table->softDeletes();
节点表 也叫用户表
public function up() { Schema::create('nodes', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('name',50)->comment('节点名称'); $table->string('route_name',100)->nullable()->default('')->comment('路由别名,权限认证标识'); $table->unsignedInteger('pid')->default(0)->comment('上级ID'); $table->enum('is_menu',['0','1'])->default('0')->comment('是否为菜单0否,1是'); $table->timestamps(); $table->softDeletes(); }); }
角色与节点中间表
Schema::create('role_node', function (Blueprint $table) { // 角色ID $table->unsignedInteger('role_id')->default(0)->comment('角色ID'); // 节点ID $table->unsignedInteger('node_id')->default(0)->comment('节点ID'); });
文章表
Schema::create('users', function (Blueprint $table) { $table->bigIncrements('id'); // 角色 $table->unsignedInteger('role_id')->default(0)->comment('角色ID'); $table->string('username',50)->comment('账号'); $table->string('truename',50)->default('未知')->comment('真实姓名'); $table->string('password',255)->comment('密码'); // nullable 可以为null $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(); // 软删除 生成一字段 deleted_at 字段 $table->softDeletes(); });
后台用户表
$table->bigIncrements('id'); // 角色 $table->unsignedInteger('role_id')->default(0)->comment('角色ID'); $table->string('username',50)->comment('账号'); $table->string('truename',50)->default('未知')->comment('真实姓名'); $table->string('password',255)->comment('密码'); // nullable 可以为null $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(); // 软删除 生成一字段 deleted_at 字段 $table->softDeletes();
标签:comment,string,default,50,rbac,四张,table,id 来源: https://www.cnblogs.com/ahao513/p/14942192.html