I have 2 models : Tours.php
public function includes()
{
return $this->belongsToMany('App\Included');
}
Included.php
public function tours()
{
return $this->belongsToMany('App\Tour');
}
and below code in my TourController.php
store
method:
if (isset($request->includeds) && isset($request->excludeds)) {
$tour->includes()->sync($request->includeds, false);
$tour->excludes()->sync($request->excludeds, false);
}
when i do dd($request->includeds);
I can see the coming values from the form but unable to sync it in my pivot table included_tour
while the code syncs excluded_tour
without any error.
Everything seems to be correct. If it is still not working try the following snippet:
public function includes()
{
return $this->belongsToMany('App\Included','included_tour', 'tour_id', 'included_id');
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments