SystemUserLevel.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. *
  4. * @author: xaboy<365615158@qq.com>
  5. * @day: 2017/11/13
  6. */
  7. namespace app\admin\model\system;
  8. use traits\ModelTrait;
  9. use basic\ModelBasic;
  10. /**
  11. * 设置会员vip model
  12. * Class SystemVip
  13. * @package app\admin\model\system
  14. */
  15. class SystemUserLevel extends ModelBasic
  16. {
  17. use ModelTrait;
  18. public static function setAddTimeAttr()
  19. {
  20. return time();
  21. }
  22. public static function getAddTimeAttr($value)
  23. {
  24. return date('Y-m-d H:i:s',$value);
  25. }
  26. /*
  27. * 获取查询条件
  28. * */
  29. public static function setWhere($where,$alert='',$model=null)
  30. {
  31. $model=$model===null ? new self() : $model;
  32. if($alert) $model=$model->alias($alert);
  33. $alert=$alert ? $alert.'.': '';
  34. if(isset($where['is_show']) && $where['is_show']!=='') $model=$model->where("{$alert}is_show",$where['is_show']);
  35. if(isset($where['title']) && $where['title']) $model=$model->where("{$alert}name",'LIKE',"%$where[title]%");
  36. return $model;
  37. }
  38. /*
  39. * 查找系统设置的会员等级列表
  40. * */
  41. public static function getSytemList($where)
  42. {
  43. $data=self::setWhere($where)->order('grade asc')->page((int)$where['page'],(int)$where['limit'])->select();
  44. $data=count($data) ? $data->toArray() : [];
  45. $count=self::setWhere($where)->count();
  46. return compact('data','count');
  47. }
  48. }