Ah. Found a solution. The problem with passing in null
is that there is a call like this
$this->createAttachRecords((array) $id, $attributes)
Which causes $id
to become an empty array when you pass in null
. To get around this you can pass in [null] which will stop the conversion and will then correctly add in a row where the id
is null
. Using your example
$group->members()->attach(
[null],
array(
'first' => $new_array[$key][0],
'last' => $new_array[$key][1],
'favorite_food' => $new_array[$key][2]
)
);
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community