I want to populate the <select> element using the results from the categories table. For this, I use the following code.
$catlist = Categories::where('type','=',$content_type) ->get(array('id','name'))->toArray();
The result structure is an array of strings.
array 0 => array 'id' => int 1 'name' => string 'article' 1 => array 'id' => int 2 'name' => string 'news'
A foreach expression will probably solve my problem, but I'm looking for a better solution.
source share