简单标签使用demo
解决已知bug
This commit is contained in:
@@ -18,22 +18,35 @@ class Channel extends \think\Model {
|
||||
'id' => 'integer',
|
||||
);
|
||||
|
||||
protected $auto = array('update_time', 'status' => 1);
|
||||
protected $insert = array('create_time');
|
||||
protected function setStatusAttr($value){
|
||||
return ($value !== '') ? $value : 1;
|
||||
}
|
||||
|
||||
protected function getStatusTextAttr($value, $data){
|
||||
$status = [0 => '禁用', 1 => '启用'];
|
||||
return isset($status[$data['status']]) ? $status[$data['status']] : '禁用';
|
||||
}
|
||||
|
||||
public static function getChannelList($pid, $tree){
|
||||
public static function getChannelList($type, $pid = '', $tree = false){
|
||||
$map = [];
|
||||
$map[] = ['status', '=', 1];
|
||||
if ($pid !== '') {
|
||||
$map[] = ['pid', '=', $pid];
|
||||
}
|
||||
|
||||
$list = self::where($map)->order('sort asc, id desc')->column("*");
|
||||
if($type !== ''){
|
||||
$map[] = ['type', '=', $type];
|
||||
}
|
||||
$list = self::where($map)->order('sort asc, id desc')->select()->each(function($item){
|
||||
if(strpos($item['url'], "?")){
|
||||
$url = parse_url($item['url']);
|
||||
$param = [];
|
||||
parse_str($url['query'], $param);
|
||||
$item['url'] = url($url['path'], $param);
|
||||
}else{
|
||||
$item['url'] = url($item['url']);
|
||||
}
|
||||
return $item;
|
||||
})->toArray();
|
||||
if ($tree) {
|
||||
$list = (new \sent\tree\Tree())->listToTree($list);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user