So I'm performing a query and getting data back like this:
[
{ "part_number": "MAC0009", "description": "Accessory Stand Foot" },
{ "part_number": "MAC0010", "description": "Accessory Stand Collar Tapped M5" },
{ "part_number": "MAC0011", "description": "Accessory Stand Top Collar" },
{ "part_number": "MAC0012", "description": "25mm Round Knob With 2 Rail Holes" }
]
However for the AJAX script I'm trying to implement I need the data in this format:
[
{ "MAC0009" : "Accessory Stand Foot" },
{ "MAC00010" : "Accessory Stand Collar Tapped M5" },
{ "MAC00012" : "Accessory Stand Top Collar" }
]
So basically I need plain data back without the table names.
All I have so far is the query.
$result = DB::table('macs')->select('part_number', 'description')->get();
Which is obviously fine but I don't know how to manipulate the data into that format :/ Any help appreciated.