1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
 
namespace app\common\model\ad;
 
use app\common\model\BaseModel;
 
/**
 * 广告分类模型
 */
class AdCategory extends BaseModel
{
    protected $name = 'ad_category';
    protected $pk = 'category_id';
 
    /**
     * 所有分类
     * @return \think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function getALL($category_id=0)
    {   
        $where = [];
        if($category_id){
            $where['category_id'] = $category_id;
        }
        $model = new static;
        return $model->where($where)->order(['create_time' => 'asc'])->select();
    }
 
}