quanwei
2 days ago 73b874c72ad55eb9eef21c36160ac0de58f0189e
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
 
namespace app\common\model\supplier;
 
use app\common\enum\supplier\SupplierType;
use app\common\model\BaseModel;
 
/**
 * 广告分类模型
 */
class Category extends BaseModel
{
    protected $name = 'supplier_category';
    protected $pk = 'category_id';
    protected $append = ['type_text'];
 
    /**
     * 所有分类
     * @return \think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function getALL($params = [])
    {
        $model = new static;
        !empty($params['category_type']) && $model=$model->where('category_type','=',$params['category_type']);
        return $model->order(['sort' => 'asc', 'create_time' => 'asc'])->select();
    }
    /**
     * 分类类型文本
     */
    public function getTypeTextAttr($value, $data)
    {
        return (new SupplierType())::getName($data['category_type']);
    }
 
    /**
     * 详情
     */
    public static function detail($category_id)
    {
       return (new static())->find($category_id);
    }
 
}