1234567891011121314151617181920 |
- <?php
- namespace app\common\model;
- use think\Model;
- // 资讯分类
- class NewsCate extends Model
- {
- /**
- * 获取分类
- */
- public static function getCates()
- {
- $list = self::where(['is_deleted'=>0,'pid'=>0])->field('id,logo,title,pid')->order('sort desc')->select();
- foreach ($list as $v){
- $child_ren = self::where(['is_deleted'=>0,'pid'=>$v->id])->field('id,logo,title,pid')->order('sort desc')->select();
- if($child_ren) $v->child_ren = $child_ren;
- }
- return $list ? $list->toArray() : [];
- }
- }
|