本文整理匯總了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;
}