口腔客户管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Doctor.php 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class Doctor extends Model
  5. {
  6. public function getDoctorSelect()
  7. {
  8. $result = $this->field('id as value,name as label')->select();
  9. return ['rows' => $result];
  10. }
  11. public function getAll($param, $page, $pageSize)
  12. {
  13. unset($param['page']);
  14. unset($param['pageSize']);
  15. foreach ($param as $k => $v) {
  16. if ($param[$k] === '' || $param[$k] === null) {
  17. unset($param[$k]);
  18. }
  19. }
  20. $where = [];
  21. if (isset($param['keyword'])) {
  22. $where[] = ['name', 'like', '%' . $param['keyword'] . '%'];
  23. unset($param['keyword']);
  24. }
  25. $result = $this->where($param)->where($where)->with(['getHospitalOneData', 'getDistrictOneData'])->limit($page, $pageSize)->select();
  26. $total = $this->where($param)->where($where)->count();
  27. $host = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['SERVER_ADDR'] . ':' . $_SERVER['SERVER_PORT'];
  28. foreach ($result as $k => $v) {
  29. $result[$k]['demand'] = array_filter(explode(',', $v['demand']));
  30. $practice_license = json_decode($v['practice_license'], true);
  31. $poster = json_decode($v['poster'], true);
  32. $pictures = json_decode($v['pictures'], true);
  33. $practice_license = (empty($practice_license)) ? [] : $practice_license;
  34. $poster = (empty($poster)) ? [] : $poster;
  35. $pictures = (empty($pictures)) ? [] : $pictures;
  36. foreach ($practice_license as $kk => $vv) {
  37. $practice_license[$kk]['url'] = $host . $vv['url'];
  38. }
  39. foreach ($pictures as $kk => $vv) {
  40. $pictures[$kk]['url'] = $host . $vv['url'];
  41. }
  42. foreach ($poster as $kk => $vv) {
  43. $poster[$kk]['url'] = $host . $vv['url'];
  44. }
  45. $result[$k]['pictures'] = $pictures;
  46. $result[$k]['poster'] = $poster;
  47. $result[$k]['practice_license'] = $practice_license;
  48. }
  49. return ['rows' => $result, 'total' => $total];
  50. }
  51. public function getDistrictOneData()
  52. {
  53. return $this->hasOne(\app\admin\model\District::class, 'adcode', 'city_id')->bind(['city_name' => 'name']);
  54. }
  55. public function getHospitalOneData()
  56. {
  57. return $this->hasOne(\app\admin\model\Hospital::class, 'id', 'hospital_id')->bind(['hospital_name' => 'name']);
  58. }
  59. // public function read($param)
  60. // {
  61. // $result = $this->where($this->getPk(), $param[$this->getPk()])->find();
  62. // if (isset($result[$this->getPk()])) {
  63. // return $result->toArray();
  64. // } else {
  65. // return [];
  66. // }
  67. // }
  68. }