SystemGroup.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. /**
  15. * 数据组model
  16. * Class SystemGroup
  17. * @package app\admin\model\system
  18. */
  19. class SystemGroup extends ModelBasic
  20. {
  21. use ModelTrait;
  22. /**
  23. * 根据id获取当前记录中的fields值
  24. * @param $id
  25. * @return array
  26. */
  27. public static function getField($id){
  28. $fields = json_decode(self::where('id',$id)->value("fields"),true);
  29. return compact('fields');
  30. }
  31. public static function getGroupDataByType($where,$page = 1, $limit = 10){
  32. $data = self::where([]);
  33. if (isset($where['config_name']) && $where['config_name']){
  34. if ($where['config_name']) {
  35. if (is_array($where['config_name'])) {
  36. $data = self::whereIn('config_name',$where['config_name']);
  37. }else{
  38. $data = self::where('config_name',$where['config_name']);
  39. }
  40. }
  41. }
  42. $data->page((int)$page, (int)$limit);
  43. $list = $data->paginate();
  44. $total = $list->total();
  45. $page = $list->render();
  46. return compact('list', 'total', 'page');
  47. }
  48. }