php - 注册表类型
问题描述
我正在尝试修改我的注册表以包含一个类型(餐厅或消费者)。我需要一个复选框,一旦选中将表明该帐户应该是餐厅。(未选中 = 消费者)。
我研究过盖茨,但这并不是我想要的。我的想法是在用户迁移中创建一个布尔属性。
播种机
public function run() {
DB::table('users')->insert([
'name' => "admin",
'email' => 'admin@test.com',
'password' => bcrypt('admin'),
// 'type' => true
]);
}
移民
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
// $table->boolean('type');
$table->rememberToken();
$table->timestamps();
});
在用户选中该框后,我希望餐厅用户能够编辑某些属性。消费者没有权限,只有查看权限。
解决方案
你可以这样 做
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->boolean('type')->default(0);
$table->rememberToken();
$table->timestamps();
});
然后你可以运行迁移:
public function run() {
DB::table('users')->insert([
'name' => "admin",
'email' => 'admin@test.com',
'password' => bcrypt('admin'),
'type' => 1
]);
}
推荐阅读
- google-cloud-firestore - 如何在 SwiftUI 中的 firebase 查询期间显示加载动画
- javascript - 如何判断一个数是否为负数,包括-0
- docker - usermod 命令大大增加了 Docker 容器的大小
- accessibility - 正确隐藏键盘和屏幕阅读器的内容
- powershell - 运行 Power shell exe 并在该 exe 中执行某些步骤
- python - 使用 %run file.py 保存答案
- visual-studio - 如何使用通过 MSVS 构建的 json 设置自动化 CMake 项目?
- c# - 将 web.config 文件添加到 Asp.Net Core 项目
- javascript - 对象中的基元更新但对象中的数组不更新
- html - 不再缩略图博客文章