/**

     * 无限级分类

     * @param $data 数组

     * @param int $pid 父级

     * @param int $lev 等级

     * @return array

     */

    public function tree($data, $pid = 0, $lev = 0)

    {

        $tree = [];

        foreach ($data as $key => $val) {

            if ($val['pid'] == $pid) {

                $val['child'] = $this->tree($data, $val['id'], $lev + 1);

                $tree[] = $val;

            }

        }

        return $tree;

    }