| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace app\api\model\service;
- use think\Model;
- class Category extends Model
- {
- // 表名
- protected $name = 'service_category';
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- /**
- * 获取分类列表
- * @param $ids
- * @return string
- */
- public function getCategoryList($ids)
- {
- if(!$ids)
- {
- return '';
- }
- $idArr = explode(',',$ids);
- $list = [];
- foreach ($idArr as $val)
- {
- $name = $this->where(['id'=>$val])->value('name');
- if($name)
- {
- $list[] = $name;
- }
- }
- return implode(',',$list);
- }
- public static function getName($id)
- {
- return self::where(['id'=>$id])->value('name');
- }
- }
|