How to sync additional fields in pivot table [Laravel 5] -


i need update additional filed user_id in pivot table... tried this:

$commet = comment::find(2); $commet->likes()->sync([2,'user_id'=>1]); 

but filed updated 0. solution this?

i think sync array isn't right. try:

$commet->likes()->sync(array(      1 => array('user_id' => 1),     2 => array('user_id' => 5),     ... )); 

ie.

sync(array(      related_id => array('pivot_field' => value),     ... )); 

Comments

Popular posts from this blog

html - Difficulties with background-image property -

visual studio code - What does the isShellCommand property actually do and how should you use it? -

ios - Segue not passing data between ViewControllers -