Laravel 5 - Database table for array with predefined index

0

Is there any way to retrieve the results of a query in the database and transform it into an array with one of the fields of the indexed array table?

You could achieve this result in two steps. After the query, it loops and transforms into the array with the desired index.

How do you ober this result in one step?

This is the code that returns me to query:

$lang = DB::table('language')->select('id', 'name')->get();

I wanted $lang to be an array of type $lang[id=>name] .

    
asked by anonymous 29.07.2016 / 23:16

0 answers