MedicalSalesman.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. public function shop()
  12. {
  13. return $this->hasOne(MedicalShop::class,'shop_id','salesman_shop_id');
  14. }
  15. /**
  16. * @Desc 手机号是否已存在
  17. * @Author Gorden
  18. * @Date 2024/3/4 9:46
  19. *
  20. * @param $phone
  21. * @return bool
  22. */
  23. public function phoneExist($phone)
  24. {
  25. return self::where('salesman_phone', $phone)->exists();
  26. }
  27. /**
  28. * @Desc 用户名是否存在
  29. * @Author Gorden
  30. * @Date 2024/3/4 10:08
  31. *
  32. * @param $username
  33. * @return bool
  34. */
  35. public function usernameExist($username)
  36. {
  37. return self::where('salesman_username', $username)->exists();
  38. }
  39. /**
  40. * @Desc 更新时,验证手机号是否在其他账号下出现
  41. * @Author Gorden
  42. * @Date 2024/3/4 10:14
  43. *
  44. * @param $phone
  45. * @param $id
  46. * @return bool
  47. */
  48. public function phoneIsInOtherAccountExist($phone, $id)
  49. {
  50. return self::where('salesman_phone', $phone)
  51. ->where('salesman_id', '<>', $id)
  52. ->exists();
  53. }
  54. /**
  55. * @Desc 更新时,验证用户名是否在其他账号下出现
  56. * @Author Gorden
  57. * @Date 2024/3/4 10:16
  58. *
  59. * @param $username
  60. * @param $id
  61. * @return bool
  62. */
  63. public function usernameIsInOtherAccountExist($username, $id)
  64. {
  65. return self::where('salesman_username', $username)
  66. ->where('salesman_id', '<>', $id)
  67. ->exists();
  68. }
  69. }