123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <?php
- namespace app\models\system;
- use crmeb\traits\ModelTrait;
- use crmeb\basic\BaseModel;
- use crmeb\services\UtilService;
- class SystemAttachmentCategory extends BaseModel
- {
-
- protected $pk = 'id';
-
- protected $name = 'system_attachment_category';
- use ModelTrait;
-
- public static function Add($name,$att_size,$att_type,$att_dir,$satt_dir='',$pid = 0)
- {
- $data['name'] = $name;
- $data['att_dir'] = $att_dir;
- $data['satt_dir'] = $satt_dir;
- $data['att_size'] = $att_size;
- $data['att_type'] = $att_type;
- $data['time'] = time();
- $data['pid'] = $pid;
- return self::create($data);
- }
-
- public static function getAll($name, $mer_id = ''){
- $model = new self;
- if($name) $model = $model->where('name','LIKE',"%$name%");
- if($mer_id) $model = $model->where('mer_id', 'in', [0, $mer_id]);
- $list=self::tidyMenuTier($model->select(),0);
- return compact('list');
- }
- public static function tidyMenuTier($menusList,$pid = 0,$navList = [])
- {
- foreach ($menusList as $k=>$menu){
- $menu = $menu->getData();
- $menu['title']=$menu['name'];
- if($menu['pid'] == $pid){
- unset($menusList[$k]);
- $menu['children'] = self::tidyMenuTier($menusList,$menu['id']);
- if ($menu['children']) $menu['expand']=true;
- $navList[] = $menu;
- }
- }
- return $navList;
- }
-
- public static function getCateList($id = 10000, $mer_id = ''){
- $model = new self();
- if($id == 0) $model = $model->where('pid',$id);
- $model = $model->where('mer_id', 'in', [0, $mer_id]);
- return sort_list_tier($model->select()->toArray());
- }
-
- public static function getinfo($att_id){
- $model = new self;
- $where['att_id'] = $att_id;
- return $model->where($where)->select()->toArray()[0];
- }
- }
|