<?php 
namespace app\common\model;
use app\common\model\Article as ArticleModel;
use think\Model;
class ArticleCate extends Model
{
	public static function getSelect($where=[])
	{
		$Data=self::where($where)->order('sort asc,id asc')->select();
		foreach ($Data as $k => $v) {
			$Data[$k]['hasChildren']=self::where(['pid'=>$v['id']])->count();
			$Data[$k]['article_sum']=ArticleModel::where(['cid'=>$v['id']])->count();
		}
		return $Data;
	}
	public static function getCateSelect()
	{
        $cate=self::field('id,pid,title,alias')->order('sort asc,id asc')->select();
        return $cate;
	}
	public static function getCate()
	{
        $cate=self::where(['pid'=>0])->field('id,title')->order('sort asc,id asc')->select();
        foreach ($cate as $k => $v) {
        	$cate[$k]['data']=self::where(['pid'=>$v['id']])->field('id,title')->order('sort asc,id asc')->select();
        }
        return $cate;
	}
}