SystemGroup.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * @author: xaboy<365615158@qq.com>
  4. * @day: 2017/11/13
  5. */
  6. namespace app\models\system;
  7. use crmeb\traits\ModelTrait;
  8. use crmeb\basic\BaseModel;
  9. /**
  10. * 数据组model
  11. * Class SystemGroup
  12. * @package app\models\system
  13. */
  14. class SystemGroup extends BaseModel
  15. {
  16. /**
  17. * 数据表主键
  18. * @var string
  19. */
  20. protected $pk = 'id';
  21. /**
  22. * 模型名称
  23. * @var string
  24. */
  25. protected $name = 'system_group';
  26. use ModelTrait;
  27. /**
  28. * 根据id获取当前记录中的fields值
  29. * @param $id
  30. * @return array
  31. */
  32. public static function getField($id)
  33. {
  34. $fields = json_decode(self::where('id', $id)->value("fields"), true) ?: [];
  35. return compact('fields');
  36. }
  37. public static function list($where)
  38. {
  39. $model = new self;
  40. if ($where['keyword'] != '') $model = $model->where('config_name|name|info', 'like', '%' . $where['keyword'] . '%');
  41. $count = $model->count();
  42. $list = $model->page((int)$where['page'], (int)$where['limit'])->select();
  43. foreach ($list as $key => $value) {
  44. $list[$key]['typelist'] = $value['fields'];
  45. unset($list[$key]['fields']);
  46. }
  47. return compact('count', 'list');
  48. }
  49. }