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
Post a Comment