0
我有2種型號:Tours.php
無法同步條件的數據透視表多對多的關係laravel
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);
我可以看到來自窗體的值,但無法在透視表included_tour
中同步它,而代碼同步excluded_tour
沒有任何錯誤。