SystemAttachmentCategory.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\admin\model\system;
  12. use traits\ModelTrait;
  13. use basic\ModelBasic;
  14. use service\UtilService;
  15. /**
  16. * 文件检验model
  17. * Class SystemFile
  18. * @package app\admin\model\system
  19. */
  20. class SystemAttachmentCategory extends ModelBasic
  21. {
  22. use ModelTrait;
  23. /**添加分类
  24. */
  25. public static function Add($name,$att_size,$att_type,$att_dir,$satt_dir='',$pid = 0 )
  26. {
  27. $data['name'] = $name;
  28. $data['att_dir'] = $att_dir;
  29. $data['satt_dir'] = $satt_dir;
  30. $data['att_size'] = $att_size;
  31. $data['att_type'] = $att_type;
  32. $data['time'] = time();
  33. $data['pid'] = $pid;
  34. return self::create($data);
  35. }
  36. /**
  37. * 获取分类图
  38. * */
  39. public static function getAll(){
  40. $model = new self;
  41. return self::tidyMenuTier($model->select(),0);
  42. }
  43. public static function tidyMenuTier($menusList,$pid = 0,$navList = [])
  44. {
  45. foreach ($menusList as $k=>$menu){
  46. $menu = $menu->getData();
  47. if($menu['pid'] == $pid){
  48. unset($menusList[$k]);
  49. $menu['child'] = self::tidyMenuTier($menusList,$menu['id']);
  50. $navList[] = $menu;
  51. }
  52. }
  53. return $navList;
  54. }
  55. /**获取分类下拉列表
  56. * @return array
  57. */
  58. public static function getCateList($id = 10000){
  59. $model = new self();
  60. if($id == 0)
  61. $model->where('pid',$id);
  62. return UtilService::sortListTier($model->select()->toArray());
  63. }
  64. /**
  65. * 获取单条信息
  66. * */
  67. public static function getinfo($att_id){
  68. $model = new self;
  69. $where['att_id'] = $att_id;
  70. return $model->where($where)->select()->toArray()[0];
  71. }
  72. }