I have sql table of this structure,
id | type | name
1 | type1 | name1
2 | type1 | name2
3 | type2 | name3
4 | type2 | name4
I want to get all the names grouped by the type like this
"type1" : [name1,name2]
"type2" : [name3,name4]
I am using Laravel eloquent, I tried keyBy('type') but it gives only one row of each type.
How can get all the names of one type?