public function get_childs( $parent_id = array(), $level = 0 ){
$id_arr = array();
$id_arr= $thisModel->where('pid','in',$parent_id)->column('id');
if (!empty($id_arr)&& $level<3) {
$level++;
$id_arr=array_merge($id_arr,get_childs($id_arr,$level));
}
return $id_arr;
}
public function getParent( $pid ,$array=[]) {
$level = 1;
$is_parent =$thisModel->where(["id"=>$pid])->find();
$array[] = $is_parent;
if ( $is_parent["pid"] ) {
$level++;
return $this->getParent( $is_parent['pid'],$array);
}
return $array;
}
$userInfo = $cateModel->where('id',10)->find();
if ($userInfo['pid']>0) {
$this->getParent($userInfo['pid']);
}
$this->get_childs([10,11]);