我正试图将属于employees表的'employee_id'插入到payrolls表中,但尽管有$fillable = ['over_time', 'notified','hours','rate', 'gross', 'employee_id']
,我还是不断收到这个错误,对此有其他解决方案吗?
Schema::create('payrolls', function (Blueprint $table) {
$table->bigIncrements('id'); $table->boolean('over_time')->default(0);
$table->boolean('notified')->default(0);
$table->integer('hours')->nullable(0);
$table->integer('rate')->nullable(0);
$table->integer('gross')->nullable(0);
$table->softDeletes(); $table->timestamps();
});
根据您的迁移,您已将hours
列定义为nullable
false,这意味着它不能为null,并且没有为该列定义default
值。
由于某些原因,您的hours
在请求中变为空白,这就是您收到此错误的原因。
$table->integer('hours')->nullable(0);
要解决此问题,请将默认值定义为小时列,如下所示,或将有效值传递给hours
列
$table->integer('hours')->default("00");