我的表投票如下:
id
user_id
votable_id
votable_type
status
我需要能够设置状态,所以我认为这样可行:
class Comment extends Model
{
public function votes(){
return $this->morphMany(Vote::class, 'votable')->withPivot('status');
}
}
然而,这会产生此错误:
BadMethodCallException with message 'Call to undefined method Illuminate\Database\Query\Builder::withPivot()'