Answer the question
In order to leave comments, you need to log in
Laravel. Selecting the necessary data from the database, and placing it in a one-dimensional array. How can be done?
You can make a cycle, but I don’t want to (laziness, you know, you quickly get used to the good).
There is a code return DB::table('category')->lists('name', 'id');
Works as it should. Returns a one-dimensional array
[
'0' => 'value1',
'1' => 'value2'
...
]
DB::table('category')
->where('primary', 'yes')
->get();
Answer the question
In order to leave comments, you need to log in
return DB::table('category')->where('primary', 'yes')->lists('name', 'id');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question