本文整理汇总了PHP中merge_tree_node函数的典型用法代码示例。如果您正苦于以下问题:PHP merge_tree_node函数的具体用法?PHP merge_tree_node怎么用?PHP merge_tree_node使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了merge_tree_node函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAllForSchemaOption
/**
* 获得全部文章分类--无限极分类(编辑菜单时选项)
*
* @descript 递归组合无限极分类,为了编辑页面和增加页面select 展示
* @param $name 表单name名称
* @param $id 当前id
* @return array
* @author yangyifan <yangyifanphp@gmail.com>
*/
public static function getAllForSchemaOption($name, $id = 0)
{
//加载函数库
load_func('common');
$data = $id > 0 ? merge_tree_node(obj_to_array(self::where('id', '<>', $id)->get())) : merge_tree_node(obj_to_array(self::all()));
array_unshift($data, ['id' => '0', $name => '顶级分类']);
return $data;
}
示例2: getAllForSchemaOption
/**
* 获得全部文章分类--无限极分类(编辑菜单时选项)
*
* @descript 递归组合无限极分类,为了编辑页面和增加页面select 展示
* @param $name 表单name名称
* @param $id 当前id
* @return array
* @author yangyifan <yangyifanphp@gmail.com>
*/
public static function getAllForSchemaOption($name, $id = 0, $first = true)
{
//加载函数库
load_func('common');
$data = $id > 0 ? merge_tree_node(obj_to_array(self::where('id', '<>', $id)->where('user_info_id', '=', is_user_login())->where('deleted_at', '=', '0000-00-00 00:00:00')->get())) : merge_tree_node(obj_to_array(self::where('user_info_id', '=', is_user_login())->get()));
$first == true && array_unshift($data, ['id' => '0', $name => '顶级分类']);
return $data;
}
示例3: getAll
/**
* 获得全部文章分类
*
* @return array
* @author yangyifan <yangyifanphp@gmail.com>
*/
public static function getAll()
{
//加载函数库
load_func('common');
$role_id = self::getRoleId();
//设置允许查看全部论坛角色组
if (in_array($role_id, config('config.forum_cat_supper_role_ids'))) {
return merge_tree_node(obj_to_array(self::mergeData(self::where('status', '=', 1)->where('deleted_at', '=', '0000-00-00 00:00:00')->get())));
}
return merge_tree_node(obj_to_array(self::mergeData(DB::table('forum_access AS fa')->join('forum_cat AS fc', 'fa.forum_cat_id', '=', 'fc.id')->where('fa.role_id', '=', $role_id)->where('fc.status', '=', 1)->where('fc.deleted_at', '=', '0000-00-00 00:00:00')->get())));
}
示例4: merge_tree_node
/**
* 组合tree节点
*
* @param $data
* @param $pid
* @param $level
* @param $parent_id
* @param $current_id
* @return array
* @auther yangyifan <yangyifanphp@gmail.com>
*/
function merge_tree_node($data, $pid = 0, $level = 0, $parent_id = 0, $current_id = 0)
{
$array = [];
if (!empty($data)) {
foreach ($data as $k => $v) {
if ($v['pid'] == $pid) {
$v['parent_id'] = $v['pid'] == 0 ? '' : ltrim($parent_id . '-' . $v['pid'], '-');
$v['current_id'] = $v['pid'] == 0 ? $v['id'] : $current_id . '-' . $v['id'];
$v['level'] = $level;
$array[] = $v;
unset($data[$k]);
$array = array_merge($array, merge_tree_node($data, $v['id'], $level + 1, $v['parent_id'], $v['current_id']));
}
}
}
return $array;
}
示例5: getAll
/**
* 获得全部文章分类
*
* @return array
* @auther yangyifan <yangyifanphp@gmail.com>
*/
public static function getAll()
{
//加载函数库
load_func('common');
return merge_tree_node(obj_to_array(self::mergeData(self::all())));
}
示例6: getAll
/**
* 获得全部文章分类
*
* @return array
* @author yangyifan <yangyifanphp@gmail.com>
*/
public static function getAll()
{
//加载函数库
load_func('common');
return merge_tree_node(obj_to_array(self::mergeData(self::where('status', '=', 1)->where('deleted_at', '=', '0000-00-00 00:00:00')->get())));
}
示例7: builderTreeData
/**
* 构建tree数据
*
* @param $data
* @return \Illuminate\View\View
* @author yangyifan <yangyifanphp@gmail.com>
*/
public function builderTreeData($data)
{
//加载函数库
load_func('common');
$this->tree_data = merge_tree_node(obj_to_array($data));
return $this;
}