<?php namespace Place\Api;
use Dever;
use Manage\Lib\Auth;
class Manage extends Auth
{
    public function getPlatformIcon($parent_id, $value, $table = false, $id = false)
    {
        if ($value) {
            if ($parent_id > 0) {
                $cate_table = 'level_3';
            } else {
                $cate_table = 'level_2';
            }
            $cate = Dever::db($cate_table, 'cate')->find($value);
            if (!$cate['icon_name']) {
                $cate['icon_name'] = $cate['name'];
            }
            if ($id) {
                $info = Dever::db($table)->find($id);
                if ($info['icon_id']) {
                    $cate['icon_id'] = $info['icon_id'];
                }
                if ($info['icon_name']) {
                    $cate['icon_name'] = $info['icon_name'];
                }
            }

            $result['icon_id']['type'] = 'selector';
            $result['icon_id']['option'] = Dever::url("cate/icon.getList", array("id" => $cate['icon_id'], "name" => $cate['icon_name']));

            return $result;
        }
    }
}