I have array of data like:
array:2 [
0 => array:1 [
"image" => "attachment-T48Pi7oAov.jpg"
]
1 => array:1 [
"image" => "attachment-IF8VG2pypn.jpg"
]
]
I need to push 2 more values into each of this arrays like:
array:2 [
0 => array:1 [
"image" => "attachment-T48Pi7oAov.jpg",
"attachable_type" => "whatever",
"attachable_id" => "whatever"
]
1 => array:1 [
"image" => "attachment-IF8VG2pypn.jpg",
"attachable_type" => "whatever",
"attachable_id" => "whatever"
]
]
If i use array_push or array_unshift it returns numbers such as 6 or 3
Code
if ($image = $request->file('attachments')) {
foreach ($image as $files) {
$filePath = public_path('images/attachment/');
$filename = 'attachment' . '-' . str_random(10) . '.' . $files->getClientOriginalExtension();
$files->move($filePath, $filename);
$names[]['image'] = "$filename";
$type['attachable_type'] = "App\ProjectScheduleVisit";
$id['attachable_id'] = "$visit->id";
$insert = array_push($names, $type, $id);
}
}
Any ideas?