I'm new to laravel. When i try to insert data using pivot values (item has many items in assembly table) , i get this error. Here is my code. I need to convert this array to an string as i understand. but how?
if (request()->has('copy_item')) {
$copy = Item::find(request('copy_item'));
$assemblies = collect($copy->assemblies)->map(function($part) {
return [
$part->id => [
'quantity' => $part->pivot->quantity,
'type' => $part->pivot->type
]
];
});
$item->assemblies()->attach($assemblies);
}