laravel - Populate select element -


i want populate <select> element using results categories table. in order use following code.

$catlist = categories::where('type','=',$content_type)            ->get(array('id','name'))->toarray();  

the result structure array of rows.

array   0 =>     array       'id' => int 1       'name' => string 'article'    1 =>     array      'id' => int 2      'name' => string 'news'  

a foreach statement surely solve problem i'm looking better solution.

you use lists(string $column [, string $key ]) method this, found under "retrieving list of column values" in documentation...

$catlist = category::where('type', $content_type)->lists('name'); 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -