0

假设我有一个 User、Roles 和 User_Role 表。我的 User_Role 表有一个自定义数据透视模型。在用户模型中,我有这样的关系

public function roles()
{
    return $this->belongsToMany(Role::class, 'User_Role')
        ->using(UserRole::class);
}

我在 UserRole 模型中有一个全局范围,它不包含在此关系中。我可以使用wherePivot()和复制范围,但我想知道这有必要吗? 有没有办法让 BelongsToMany 关系尊重在 Pivot 模型中定义的全局范围

4

0 回答 0