UserMedicalExaminationReport.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace app\admin\model;
  3. use support\Model;
  4. class UserMedicalExaminationReport extends Model
  5. {
  6. /**
  7. * The table associated with the model.
  8. *
  9. * @var string
  10. */
  11. protected $table = 'user_medical_examination_report';
  12. /**
  13. * The primary key associated with the table.
  14. *
  15. * @var string
  16. */
  17. protected $primaryKey = 'report_id';
  18. /**
  19. * Indicates if the model should be timestamped.
  20. *
  21. * @var bool
  22. */
  23. public $timestamps = false;
  24. /**
  25. * Notes:检测是否存在
  26. * @param string $group
  27. * @return bool
  28. * User: yym
  29. * Date: 2022/9/15
  30. */
  31. public static function checkStatus(string $group)
  32. {
  33. return static::where(['report_group' => $group])->exists();
  34. }
  35. /**
  36. * Notes:插入数据
  37. * @param array $data
  38. * @return false|int
  39. * User: yym
  40. * Date: 2022/9/15
  41. */
  42. public static function insertData(array $data)
  43. {
  44. if(empty($data))
  45. {
  46. return false;
  47. }
  48. return static::insertGetId($data);
  49. }
  50. /**
  51. * Notes:更新数据
  52. * @param string $group
  53. * @param array $data
  54. * @return false|int
  55. * User: yym
  56. * Date: 2022/9/15
  57. */
  58. public static function updateData(string $group, array $data)
  59. {
  60. if(empty($group) || empty($data))
  61. {
  62. return false;
  63. }
  64. return static::where(['report_group' => $group])->update($data);
  65. }
  66. /**
  67. * Notes:获取会员体检信息
  68. * @param int $user_id
  69. * @return array
  70. * User: yym
  71. * Date: 2022/9/21
  72. */
  73. public static function getList(int $user_id)
  74. {
  75. $list = static::where(['report_user_id' => $user_id])
  76. ->orderBy('report_time', 'desc')
  77. ->get()
  78. ->toArray();
  79. $count = static::where(['report_user_id' => $user_id])->count();
  80. return [$list, $count];
  81. }
  82. }