学了几天Laravel,遇到了一个问题。我有这些迁移:Schema::create('companies', function (Blueprint $table) { $table->bigIncrements('id'); $table->boolean('enable')->default(0); $table->string('name', 85)->nullable(); $table->string('nip', 12)->nullable(); $table->mediumText('content')->nullable(); $table->string('street', 150)->nullable(); $table->string('number', 8)->nullable(); $table->string('postal_code', 12)->nullable(); $table->string('city', 100)->nullable(); $table->bigInteger('country_id')->default(0); $table->bigInteger('provincial_id')->default(0); $table->string('contact_person', 85)->nullable(); $table->string('email', 120)->nullable(); $table->string('www', 120)->nullable(); $table->string('phone', 25)->nullable(); $table->string('regon', 20)->nullable(); $table->string('key_to_program', 50)->nullable(); $table->decimal('lng', 10, 8)->default(0); $table->decimal('lat', 10, 8)->default(0); $table->boolean('enable_map')->default(0); $table->string('street2', 150)->nullable(); $table->string('number2', 8)->nullable(); $table->string('postal_code2', 12)->nullable(); $table->string('city2', 100)->nullable(); }); 我的 RegisterController.phpprotected function create(array $data) { $user = User::create([ 'name' => $data['name'], 'surname' => $data['surname'], 'email' => $data['email'], 'password' => Hash::make($data['password']), 'url_address' => Str::slug($data['name'], '-'), 'ip' => RequestFacade::ip(), 'company_id' => 1, 'country_id1' => 1, 'provincial_id1' => 1, ]);我在表“公司”中有公司,id = 1。注册正确进行,但并非所有字段都添加到数据库中。当我注册一个新用户时,我的列 ID 为空:country_id1 和 Province_id1。
1 回答
至尊宝的传说
TA贡献1789条经验 获得超10个赞
检查 User 类中的 $fillable 变量。company_id1 和 Province_id1 必须在可填充变量中定义。
$fillable = [
'name',
'surname',
'email',
'url_address',
'country_id1',
'provincial_id1'
etc...
];
- 1 回答
- 0 关注
- 107 浏览
添加回答
举报
0/150
提交
取消