UserDoctorsLog.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace app\admin\model;
  3. use support\Db;
  4. use support\Model;
  5. /**
  6. * 用户医嘱模型
  7. * Class Users
  8. * @package app\admin\model
  9. */
  10. class UserDoctorsLog extends Model
  11. {
  12. /**
  13. * The table associated with the model.
  14. *
  15. * @var string
  16. */
  17. protected $table = 'user_doctors_log';
  18. public $timestamps = false;
  19. /**
  20. * Notes:获取会员医生医嘱列表
  21. * @param int $log_user_id
  22. * @param int $page
  23. * @param int $limit
  24. * @return array
  25. * User: ZQ
  26. * Date: 2022/12/8
  27. */
  28. public static function doctorLogList(int $log_user_id, int $page, int $limit)
  29. {
  30. $list = static::where('user_doctors_log.log_user_id', '=', $log_user_id)
  31. ->select('user_doctors_log.*','medical_care_doctor.doctor_name','medical_care_subject.subject_name','user.user_real_name','user.user_phone')
  32. ->orderBy('user_doctors_log.log_add_time', 'desc')
  33. ->leftJoin('medical_care_doctor','doctor_id','=','user_doctors_log.log_doctor_id')
  34. ->leftJoin('medical_care_subject','subject_id','=','user_doctors_log.log_subject_id')
  35. ->leftJoin('user','user_id','=','user_doctors_log.log_user_id')
  36. ->forPage($page, $limit)
  37. ->get()
  38. ->toArray();
  39. $count = static::where('user_doctors_log.log_user_id', '=', $log_user_id)
  40. ->count();
  41. return [$list, $count];
  42. }
  43. }