I've a sample collection
#items: array:4 [▼
0 => Collection {#465 ▼
#items: array:2 [▼
"id" => 1
"user_id" => 5
]
}
1 => Collection {#455 ▼
#items: array:2 [▼
"id" => 2
"user_id" => 5
]
}
2 => Collection {#419 ▼
#items: array:2 [▼
"id" => 3
"user_id" => 1
]
}
3 => Collection {#410 ▼
#items: array:2 [▼
"id" => 4
"user_id" => 1
]
}
]
}
how can I aggregate the above collection to the below collection. It is the count of ids for every user_id's.
#items: array:2 [▼
0 => Collection {#465 ▼
#items: array:2 [▼
"user_id" => 1
"count" => 2
]
}
1 => Collection {#455 ▼
#items: array:2 [▼
"user_id" => 5
"count" => 2
]
}
]
}
Any suggestions would be appreciated.