我正在尝试制作一个存储模型动作日志的多态关系船
public function audits($model = null){
$modelClass = $model ? (new $model)->getMorphClass() : $this->getMorphClass();
return $this->morphToMany(Audit::class, 'auditable', 'EntityAudit', 'AuditableType', 'AuditableID')
->wherePivot('AuditedType', $modelClass)
->wherePivot('AuditableType', $this->getMorphClass());
}
public function audit($model): bool {
$this->audits()->attach($this->getKey());
}
现在,当运行此审核功能时,我会收到此错误。
[SQL Server]Invalid column name 'auditable_type'
但是在我的关系中,我给它使用了正确的列。如何告诉Attach使用正确的列创建关系?我找不到能帮助我解决这个问题的东西。