哪里放显示树逻辑?

时间:2014-08-21 09:29:28

标签: laravel laravel-4

我有一个构建类别树的函数:

public static function buildSelectTree($tree, $step = 0) {
    $result = '';

    foreach ($tree as $element) {
        $result .= "<option>";
        $result .= str_repeat('--', $step) . ' ' . $element->name;
        $result .= '</option>';

        if ($element->children) {
            $result .= self::buildSelectTree($element->children, $step + 1);
        }
    }

    return $result;
}

将它放入模型中是否可以?或者我应该把它放在其他地方?我不喜欢在模型中使用html的想法

0 个答案:

没有答案
相关问题