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

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -