public function get_children_cate($parent_id){
$childrens_arr = array();
//check have children
$children_cnt = DB::table('pms_product_category')->where('parentId', $parent_id)->count();
if($children_cnt > 0){
//get children by parent ids
$childrens = DB::table('pms_product_category')->where('parentId', $parent_id)->get()->toArray();
foreach($childrens as $row){
$children = $this->get_children_cate($row->id);
if(!empty($
$row->children = $children;
}
$childrens_arr[] = $row;
}
}
return json_decode(json_encode($childrens_arr), true);
}