SystemUserLevel.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace app\admin\model\system;
  3. use crmeb\traits\ModelTrait;
  4. use crmeb\basic\BaseModel;
  5. /**
  6. * 设置会员vip model
  7. * Class SystemVip
  8. * @package app\admin\model\system
  9. */
  10. class SystemUserLevel extends BaseModel
  11. {
  12. /**
  13. * 数据表主键
  14. * @var string
  15. */
  16. protected $pk = 'id';
  17. /**
  18. * 模型名称
  19. * @var string
  20. */
  21. protected $name = 'system_user_level';
  22. use ModelTrait;
  23. public static function setAddTimeAttr()
  24. {
  25. return time();
  26. }
  27. public static function getAddTimeAttr($value)
  28. {
  29. return date('Y-m-d H:i:s', $value);
  30. }
  31. /**
  32. * 获取查询条件
  33. * @param $where
  34. * @param string $alert
  35. * @param null $model
  36. * @return SystemUserLevel|null
  37. */
  38. public static function setWhere($where, $alert = '', $model = null)
  39. {
  40. $model = $model === null ? new self() : $model;
  41. if ($alert) $model = $model->alias($alert);
  42. $alert = $alert ? $alert . '.' : '';
  43. $model = $model->where("{$alert}is_del", 0);
  44. if (isset($where['is_show']) && $where['is_show'] !== '') $model = $model->where("{$alert}is_show", $where['is_show']);
  45. if (isset($where['title']) && $where['title']) $model = $model->where("{$alert}name", 'LIKE', "%$where[title]%");
  46. return $model;
  47. }
  48. /**
  49. * 查找系统设置的会员等级列表
  50. * @param $where
  51. * @return array
  52. */
  53. public static function getSytemList($where)
  54. {
  55. $data = self::setWhere($where)->order('grade asc')->page((int)$where['page'], (int)$where['limit'])->select();
  56. $data = count($data) ? $data->toArray() : [];
  57. $count = self::setWhere($where)->count();
  58. return compact('data', 'count');
  59. }
  60. }