<?php namespace Place_source\Api;
use Dever;
use Manage\Lib\Auth;
class Manage extends Auth
{
    public function getInfo()
    {
        return Dever::load('common', 'manage')->cascader(2, function($level, $parent) {
            if ($level == 1) {
                $data = Dever::db('info', 'place_source')->select([]);
            } elseif ($level == 2) {
                $data = Dever::db('sku', 'place_source')->select(array('info_id' => $parent));
                if ($data) {
                    foreach ($data as &$v) {
                        $v['name'] = Dever::load('sku', 'api')->getName($v['key'], 'place_source');
                        if (!$v['name']) {
                            $v['name'] = '无规格';
                        }
                    }
                }
            }
            return $data;
        });
    }
}