User.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Auth\Authenticatable;
  4. use Laravel\Lumen\Auth\Authorizable;
  5. use Illuminate\Database\Eloquent\Model;
  6. use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
  7. use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
  8. use Tymon\JWTAuth\Contracts\JWTSubject;
  9. class User extends Model implements AuthenticatableContract, AuthorizableContract, JWTSubject
  10. {
  11. use Authenticatable, Authorizable;
  12. /**
  13. * The attributes that are mass assignable.
  14. *
  15. * @var array
  16. */
  17. // protected $fillable = [
  18. // 'name', 'id'
  19. // ];
  20. protected $guarded = [];
  21. /**
  22. * The attributes excluded from the model's JSON form.
  23. *
  24. * @var array
  25. */
  26. protected $hidden = [
  27. 'password',
  28. ];
  29. /**
  30. * Get the identifier that will be stored in the subject claim of the JWT.
  31. *
  32. * @return mixed
  33. */
  34. public function getJWTIdentifier()
  35. {
  36. return $this->getKey();
  37. }
  38. /**
  39. * Return a key value array, containing any custom claims to be added to the JWT.
  40. *
  41. * @return array
  42. */
  43. public function getJWTCustomClaims()
  44. {
  45. return ['role' => 'user'];
  46. }
  47. // 注册来源
  48. const REGISTER_SOURCE_WEAPP = 'weapp';
  49. public static $registerSourceMaps = [
  50. self::REGISTER_SOURCE_WEAPP => '微信小程序'
  51. ];
  52. //账号状态
  53. const STATUS_OK = 1;
  54. const STATUS_PAUSE = 0;
  55. public static $statusMaps = [
  56. self::STATUS_PAUSE => '暂停使用',
  57. self::STATUS_OK => '正常'
  58. ];
  59. // 认证状态
  60. const CARD_OK = 1;
  61. const CARD_NO = 0;
  62. public static $cardMaps = [
  63. self::CARD_OK => '已实名认证',
  64. self::CARD_NO => '未实名认证'
  65. ];
  66. // 押金状态
  67. const DEPOSIT_OK = 1;
  68. const DEPOSIT_NO = 0;
  69. public static $depositMaps = [
  70. self::DEPOSIT_OK => '已缴纳押金',
  71. self::DEPOSIT_NO => '未缴纳押金',
  72. ];
  73. const DEPOSIT_MONEY = 1;
  74. const DEPOSIT_CARD = 2;
  75. const DEPOSIT_TYPE_NO = 0;
  76. public static $depositTypeMaps = [
  77. self::DEPOSIT_TYPE_NO => '没有缴纳押金',
  78. self::DEPOSIT_MONEY => '缴纳押金',
  79. self::DEPOSIT_CARD => '免押金卡',
  80. ];
  81. // 是否到了骑车年龄的状态
  82. const RIDE_BIKE_AGE_OK = 1;
  83. const RIDE_BIKE_AGE_NO = 0;
  84. public static $rideBikeAgeMaps = [
  85. self::RIDE_BIKE_AGE_OK => '已到骑车的年龄',
  86. self::RIDE_BIKE_AGE_NO => '未到骑车的年龄'
  87. ];
  88. // 手机号绑定状态
  89. const BIND_MOBILE_OK = 1;
  90. const BIND_MOBILE_NO = 0;
  91. public static $bingMobileMaps = [
  92. self::BIND_MOBILE_OK => '已绑定收手机号',
  93. self::BIND_MOBILE_NO => '未绑定手机号'
  94. ];
  95. // 用户授权状态
  96. const REGISTER_OK = 1;
  97. const REGISTER_NO = 0;
  98. public static $registerMaps = [
  99. self::REGISTER_OK => '已授权',
  100. self::REGISTER_NO => '未授权'
  101. ];
  102. public function auth()
  103. {
  104. return $this->hasOne(Auth::class)->where('type', Auth::TYPE_WEAPP);
  105. }
  106. public function userPhoneDetail()
  107. {
  108. return $this->hasOne(UserPhoneDetail::class);
  109. }
  110. }