with laravel 5.2,I have 2 models called order and worker (Many to Many relationship)
public function workers()
{
return $this->belongsToMany('App\Worker')->withTimestamps();
}
and ..
public function orders()
{
return $this->belongsToMany('App\Order')->withTimestamps();
}
the pivot table cantains field called assignment id | order_id | worker_id | assignment
I need to sync() where the assignment field is reassigned ..
$order->workers()->where('assignment','Reassigned')->sync($workers);
that does not work ..
If you have pivot variables:
Relationship if you have pivot variables:
$workers array:
If you don't have pivot variables send and array of orders id's
Edit:
Try with the where clausule in a new function
And after:
use
withPivotValue
function in model relation likeand then call
Sync
function as usual you call itDon't know will it work or not (not available test it right now), but try
wherePivot
method