Merge Two Collections Containing Same IDs In Laravel
Let’s say you have two Collections with the same ID. $a = collect([ ‘id’ => 1, ‘name’ => ‘Johnny’ ]); $b = collect([ ‘id’ => 1, ‘age’ => 14 ]); There’s not a helper to merge the two for a result like this. $c = [ ‘id’ => 1, ‘name’ => ‘Johnny’, ‘age’ => 14]; … Read more