UserApply.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * @author: xaboy<365615158@qq.com>
  4. * @day: 2017/11/11
  5. */
  6. namespace app\admin\model\user;
  7. use crmeb\traits\ModelTrait;
  8. use crmeb\basic\BaseModel;
  9. use think\model\concern\SoftDelete;
  10. /**
  11. * Class StoreCategory
  12. * @package app\admin\model\store
  13. */
  14. class UserApply extends BaseModel
  15. {
  16. /**
  17. * 数据表主键
  18. * @var string
  19. */
  20. protected $pk = 'id';
  21. /**
  22. * 模型名称
  23. * @var string
  24. */
  25. protected $name = 'user_apply';
  26. use ModelTrait;
  27. protected $autoWriteTimestamp = true;
  28. public static function list($where)
  29. {
  30. $model = self::alias('a')->field('a.*,u.nickname')->order('a.id DESC')
  31. ->leftJoin('user u', 'a.uid = u.uid');
  32. if ($where['name'])$model->where('u.uid|u.nickname' , 'like', '%'.$where['name'].'%');
  33. if ($where['status']){
  34. if ($where['status'] == 1){
  35. $model->where('a.status' , 0);
  36. }elseif ($where['status'] == 2){
  37. $model->where('a.status' , 1);
  38. }elseif ($where['status'] == 3){
  39. $model->where('a.status' , -1);
  40. }
  41. }
  42. $data['count'] = $model->count();
  43. if ($where['page'] && $where['limit']){
  44. $model->page($where['page'], $where['limit']);
  45. }else{
  46. $model->page(20, 1);
  47. }
  48. $list = $model->select()->toArray();
  49. $data['data'] = $list;
  50. return $data;
  51. }
  52. }