Closed lacroix005 closed 7 years ago
after many tinkering with all available function (and reading all the issue) i found the solution.
$data = Category::where('parent_id', '0')->get();
$kategoris = nestable()->make($data)->attr(['name' => 'category_id', 'class' =>'form-control'])
->selected($selected)
->renderAsDropdown();
it will be nice if there are shortcut in the future
when i am only want to show where parent_id = 0 i got error "Call to undefined method Illuminate\Database\Query\Builder::attr()"
example =
$kategoris = Category::where('parent_id', '=', 0)->attr(['name' => 'category_id', 'class' =>'form-control']) ->selected($selected) ->renderAsDropdown();
if i use parent(0) all the child is rendered. $kategoris = Category::parent(0)->attr(['name' => 'category_id', 'class' =>'form-control']) ->selected($selected) ->renderAsDropdown();
I only want show where parent_id == 0. can someone help me??