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
Post a Comment