<?php namespace Cate\Lib;
use Dever;
class Goods
{
    public function getManageList()
    {
        $where = array('status' => 1);
        $parent = Dever::db('goods_level_1', 'cate')->select($where);
        $result = array();
        foreach ($parent as $k => $v) {
            $where['parent_id'] = $v['id'];
            $v['children'] = Dever::db('goods_level_2', 'cate')->select($where);
            $result[] = $v;
        }
        return $result;
    }

    public function updateManageCate($db, $data)
    {
        if ($data['parent']) {
            $parent = explode(',', $data['parent']);
            $data['top_id'] = $parent[0];
            if (isset($parent[1])) {
                $data['parent_id'] = $parent[1];
            }
        }
        return $data;
    }
}