SystemUserLevel.php 1.8 KB

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