MedicalSalesman.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace app\model;
  3. use support\Model;
  4. class MedicalSalesman extends Model
  5. {
  6. protected $table = 'medical_salesman';
  7. protected $primaryKey = 'salesman_id';
  8. protected $dateFormat = 'U';
  9. public const CREATED_AT = 'salesman_addTime';
  10. public const UPDATED_AT = 'salesman_updateTime';
  11. /**
  12. * @Desc 手机号是否已存在
  13. * @Author Gorden
  14. * @Date 2024/3/4 9:46
  15. *
  16. * @param $phone
  17. * @return bool
  18. */
  19. public function phoneExist($phone)
  20. {
  21. return self::where('salesman_phone', $phone)->exists();
  22. }
  23. /**
  24. * @Desc 用户名是否存在
  25. * @Author Gorden
  26. * @Date 2024/3/4 10:08
  27. *
  28. * @param $username
  29. * @return bool
  30. */
  31. public function usernameExist($username)
  32. {
  33. return self::where('salesman_username', $username)->exists();
  34. }
  35. /**
  36. * @Desc 更新时,验证手机号是否在其他账号下出现
  37. * @Author Gorden
  38. * @Date 2024/3/4 10:14
  39. *
  40. * @param $phone
  41. * @param $id
  42. * @return bool
  43. */
  44. public function phoneIsInOtherAccountExist($phone, $id)
  45. {
  46. return self::where('salesman_phone',$phone)
  47. ->where('salesman_id','<>',$id)
  48. ->exists();
  49. }
  50. /**
  51. * @Desc 更新时,验证用户名是否在其他账号下出现
  52. * @Author Gorden
  53. * @Date 2024/3/4 10:16
  54. *
  55. * @param $username
  56. * @param $id
  57. * @return bool
  58. */
  59. public function usernameIsInOtherAccountExist($username,$id)
  60. {
  61. return self::where('salesman_username',$username)
  62. ->where('salesman_id','<>',$id)
  63. ->exists();
  64. }
  65. }