SystemAttachmentCategory.php 2.1 KB

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