sort of
{!! Form::select('category_id', listSelect(App\Category::all()), null, array('class' => 'form-control','multiple' => TRUE)) !!}
// add to /app/helpers.php
function listSelect($categories){
$cats = $parents = array();
$cats['-1']= 'Select Category';
foreach ($categories as $category) {
if ($category->parent_id == 0) {
$parents[$category->id] = $category->name;
$cats[$category->name]=array();
}
}
foreach ($categories as $category) {
if($category->parent_id > 0) {
$parent_name = $parents[$category->parent_id];
$cats[$parent_name][$category->id]=$category->name;
}
}
return $cats;
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community