Student.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\admin\model\educational;
  12. use traits\ModelTrait;
  13. use basic\ModelBasic;
  14. use app\admin\model\educational\Classes;
  15. /**
  16. * 学员 Model
  17. * Class Student
  18. * @package app\admin\model\educational
  19. */
  20. class Student extends ModelBasic
  21. {
  22. use ModelTrait;
  23. public static function setWhere($where)
  24. {
  25. $model = self::order('sort desc,add_time desc')->where('is_del', 0);
  26. if (isset($where['cid']) && $where['cid']) $model = $model->where('classes_id', $where['cid']);
  27. if (isset($where['title']) && $where['title'] != '') $model = $model->where('name|nickname|id', 'like', "%$where[title]%");
  28. return $model;
  29. }
  30. /**学员列表
  31. * @param $where
  32. */
  33. public static function getStudentLists($where)
  34. {
  35. $data = self::setWhere($where)->page($where['page'], $where['limit'])->select();
  36. foreach ($data as $key => &$value) {
  37. $value['title'] = Classes::where('id', $value['classes_id'])->value('title');
  38. $value['address'] = $value['province'] . $value['city'] . $value['district'] . $value['detail'];
  39. $value['sex'] = $value['sex'] == 1 ? '男' : '女';
  40. }
  41. $count = self::setWhere($where)->count();
  42. return compact('data', 'count');
  43. }
  44. }