I have a list of items in database table of a structure: id, name.
I need to populate a select box with items sorted by their names along with "All" element with an id = 0 as the first one. What is wrong is that the element doesn't appear in a list box at all.
Controller method:
public function getItems(){
$items = Item::orderBy('name', 'ASC')->lists('name', 'id');
$items_all = array(0 => 'All');
array_merge($items_all, $items);
return View::make('items')->with('items', $items);
}
and a view:
{{ Form::select('item_id', $items, Input::Get('item_id'), array('class'=>'form-control')) }}