更新目录结构
This commit is contained in:
@@ -1,37 +1,2 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
use think\facade\Cache;
|
||||
use sent\tree\Tree;
|
||||
|
||||
function getDepartmentChild($pid = 0){
|
||||
$department = Cache::get('department');
|
||||
if(!$department){
|
||||
$department = \app\model\auth\Departments::where('status', '=', 1)->column('id,parent_id,title', 'id');
|
||||
Cache::set('department', $department);
|
||||
}
|
||||
$res = getChilds($department, $pid, 'id', 'parent_id');
|
||||
$res[] = (int) $pid; //把自己包含在内
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得所有的子
|
||||
* @param [type] $id [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
function getChilds($data, $id = 0, $pk = 'id', $pid = 'parent_id') {
|
||||
$array = [];
|
||||
foreach ($data as $k => $v) {
|
||||
if ($v[$pid] == $id) {
|
||||
$array[] = $v[$pk];
|
||||
$array = array_merge($array, getChilds($data, $v[$pk]));
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
// 应用公共文件
|
||||
|
||||
Reference in New Issue
Block a user