我有两个表通过hasMany关系链接。一个是成员。
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Member extends Model
{
protected $fillable = ['name', 'email'];
public function schools()
{
return $this->hasMany(School::class);
}
}
另一个是学校。
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class School extends Model
{
protected $fillable = ['school'];
public function member()
{
return $this->hasMany(Member::class);
}
}
我想提交一个用户填写的表单但不幸的是,我收到以下错误。
General error: 1364 Field 'member_id' doesn't have a default value (SQL: insert into `schools` (`school`, `updated_at`, `created_at`) values (Eton, 2017-05-26 13:28:50, 2017-05-26 13:28:50))