简单标签使用demo

解决已知bug
This commit is contained in:
2020-04-22 21:32:36 +08:00
parent 5ae9d68948
commit 676c5854cd
12 changed files with 40 additions and 144 deletions

View File

@@ -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);
}