<?php

namespace Push\Lib;

use Dever;

class Manage
{
    //{source_id} > 0 ? ("{name}" ? "{name}" : Dever::load("sad/supply-one#name", {source_id})) : "{name}"
    public function name($id)
    {
        $info = Dever::db('push/data')->one($id);

        if ($info['name']) {
            return $info['name'];
        }

        if ($info['type'] < 10) {
            $audit = array
            (
                //'audit' => 2,
                //'status' => 2,
                'state' => 1,
            );
            if ($info['type'] == 1) {
                $audit['id'] = $info['demand_id'];
                $data = Dever::db('demand/info')->one($audit);
            }

            if (isset($data) && $data && isset($data['name'])) {
                return $data['name'];
            }
        }

        return $info['name'];
    }
}