123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace app\common\model\store;
- use app\common\model\BaseModel;
- use think\Model;
- class StoreCategory extends BaseModel
- {
- /**
- * @return string
- * @author zfy
- * @day 2020-03-30
- */
- public static function tablePk(): string
- {
- return 'store_category_id';
- }
- /**
- * @return string
- * @author zfy
- * @day 2020-03-30
- */
- public static function tableName(): string
- {
- return 'store_category';
- }
- /**
- * 获取父级名称
- * @Author:Qinii
- * @Date: 2020/5/22
- * @param $value
- * @return string
- */
- public function getAncestorsAttr($value)
- {
- $value = self::whereIn('store_category_id',$this->path_ids)->order('level ASC')->column('cate_name');
- return implode('/',$value).'/'.$this->cate_name;
- }
- /**
- * 获取path的id
- * @Author:Qinii
- * @Date: 2020/5/22
- * @return array
- */
- public function getPathIdsAttr()
- {
- return explode('/',$this->path);
- }
- /**
- * 获取子集id
- * @Author:Qinii
- * @Date: 2020/5/22
- * @param $value
- * @return array
- */
- public function getChildIdsAttr($value)
- {
- return self::where('path','like','%/'.$this->store_category_id.'/%')->column('store_category_id');
- }
- public function searchIdsAttr($query,$value)
- {
- $query->where('store_category_id','in',$value);
- }
- }
|