无法同步条件数据透视 table 多对多关系 laravel

Unable to sync conditional pivot table many to many relationship laravel

我有 2 个模型:Tours.php

 public function includes()
{
    return $this->belongsToMany('App\Included');
}

Included.php

public function tours()
{
    return $this->belongsToMany('App\Tour');
}

我的 TourController.php store 方法中的以下代码:

if (isset($request->includeds) && isset($request->excludeds)) {
      $tour->includes()->sync($request->includeds, false);
      $tour->excludes()->sync($request->excludeds, false);
}

当我这样做时 dd($request->includeds); 我可以看到来自表单的即将到来的值但无法在我的数据透视表中同步它 table included_tour 而代码同步 excluded_tour 没有任何错误。

一切似乎都是正确的。如果仍然无法正常工作,请尝试以下代码段:

    public function includes()
{
    return $this->belongsToMany('App\Included','included_tour', 'tour_id', 'included_id');
}