<?php
namespace app\index\model;
use think\Model;

// 引入框架内置类
use think\facade\Db;
use think\facade\Event;
use think\facade\Session;
use think\facade\Request;

class CateContent extends Model{
	
    // 定义时间戳字段名
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';

	//Index/Lists/index 
	public static function info($id){
		$info =Db::name('cate')->alias('a')->join('cate_content c', 'a.id=c.cate_id', 'left')->field('a.*,c.*')->where('id',$id)->find();
		return $info;
	}
	
	
	//网站顶部菜单、一级菜单
	public static function get_menu($type,$limit){
		$map['is_effect']=1;
		if($type==2){
		$map['is_foot']=1;
		}else{
		$map['is_top']=1;
		}
		$list =Db::name('cate')->alias('a')->join('cate_content c', 'a.id=c.cate_id', 'left')->field('a.*,c.*')->where($map)->limit($limit)->order('sort asc')->select()->toArray();
		return $list;
	}
	
	//网站菜单下拉、二级菜单
	public static function menu_cate($pid,$limit){
		$map['is_effect']=1;
		$map['pid']=$pid;
		$map['is_down']=1;
		$list =Db::name('cate')->alias('a')->join('cate_content c', 'a.id=c.cate_id', 'left')->field('a.*,c.*')->where($map)->limit($limit)->order('sort asc')->select()->toArray();
		return $list;
	}
	
	//获取网站栏目cate_list、二级菜单
	public static function cate_list($pid,$limit){
		$map['is_effect']=1;
		$map['pid']=$pid;
		$list =Db::name('cate')->alias('a')->join('cate_content c', 'a.id=c.cate_id', 'left')->field('a.*,c.*')->where($map)->limit($limit)->order('sort asc')->select()->toArray();
		return $list;
	}
	
}