User.php 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. namespace App\Models;
  3. use Auth;
  4. use Illuminate\Database\Eloquent\Builder;
  5. use Illuminate\Foundation\Auth\User as Authenticatable;
  6. use Illuminate\Notifications\Notifiable;
  7. /**
  8. * 用户信息
  9. *
  10. * @property int $id
  11. * @property string $username 昵称
  12. * @property string $email 邮箱
  13. * @property string $password 密码
  14. * @property int $port 代理端口
  15. * @property string $passwd 代理密码
  16. * @property string $vmess_id
  17. * @property int $transfer_enable 可用流量,单位字节,默认1TiB
  18. * @property int $u 已上传流量,单位字节
  19. * @property int $d 已下载流量,单位字节
  20. * @property int $t 最后使用时间
  21. * @property string|null $ip 最后连接IP
  22. * @property int $enable 代理状态
  23. * @property string $method 加密方式
  24. * @property string $protocol 协议
  25. * @property string|null $protocol_param 协议参数
  26. * @property string $obfs 混淆
  27. * @property int $speed_limit 用户限速,为0表示不限速,单位Byte
  28. * @property string|null $wechat 微信
  29. * @property string|null $qq QQ
  30. * @property int $credit 余额,单位分
  31. * @property string|null $enable_time 开通日期
  32. * @property string $expire_time 过期时间
  33. * @property int $ban_time 封禁到期时间
  34. * @property string|null $remark 备注
  35. * @property int $level 等级,默认0级
  36. * @property int $is_admin 是否管理员:0-否、1-是
  37. * @property string $reg_ip 注册IP
  38. * @property int $last_login 最后登录时间
  39. * @property int $referral_uid 邀请人
  40. * @property string|null $reset_time 流量重置日期,NULL表示不重置
  41. * @property int $invite_num 可生成邀请码数
  42. * @property int $status 状态:-1-禁用、0-未激活、1-正常
  43. * @property string|null $remember_token
  44. * @property \Illuminate\Support\Carbon|null $created_at
  45. * @property \Illuminate\Support\Carbon|null $updated_at
  46. * @property-read \Illuminate\Notifications\DatabaseNotificationCollection|\Illuminate\Notifications\DatabaseNotification[] $notifications
  47. * @property-read int|null $notifications_count
  48. * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Payment[] $payment
  49. * @property-read int|null $payment_count
  50. * @property-read \App\Models\User|null $referral
  51. * @property-read \App\Models\UserSubscribe|null $subscribe
  52. * @method static Builder|User newModelQuery()
  53. * @method static Builder|User newQuery()
  54. * @method static Builder|User query()
  55. * @method static Builder|User uid()
  56. * @method static Builder|User whereBanTime($value)
  57. * @method static Builder|User whereCreatedAt($value)
  58. * @method static Builder|User whereCredit($value)
  59. * @method static Builder|User whereD($value)
  60. * @method static Builder|User whereEmail($value)
  61. * @method static Builder|User whereEnable($value)
  62. * @method static Builder|User whereEnableTime($value)
  63. * @method static Builder|User whereExpireTime($value)
  64. * @method static Builder|User whereId($value)
  65. * @method static Builder|User whereInviteNum($value)
  66. * @method static Builder|User whereIp($value)
  67. * @method static Builder|User whereIsAdmin($value)
  68. * @method static Builder|User whereLastLogin($value)
  69. * @method static Builder|User whereLevel($value)
  70. * @method static Builder|User whereMethod($value)
  71. * @method static Builder|User whereObfs($value)
  72. * @method static Builder|User wherePasswd($value)
  73. * @method static Builder|User wherePassword($value)
  74. * @method static Builder|User wherePort($value)
  75. * @method static Builder|User whereProtocol($value)
  76. * @method static Builder|User whereProtocolParam($value)
  77. * @method static Builder|User whereQq($value)
  78. * @method static Builder|User whereReferralUid($value)
  79. * @method static Builder|User whereRegIp($value)
  80. * @method static Builder|User whereRemark($value)
  81. * @method static Builder|User whereRememberToken($value)
  82. * @method static Builder|User whereResetTime($value)
  83. * @method static Builder|User whereSpeedLimit($value)
  84. * @method static Builder|User whereStatus($value)
  85. * @method static Builder|User whereT($value)
  86. * @method static Builder|User whereTransferEnable($value)
  87. * @method static Builder|User whereU($value)
  88. * @method static Builder|User whereUpdatedAt($value)
  89. * @method static Builder|User whereUsername($value)
  90. * @method static Builder|User whereVmessId($value)
  91. * @method static Builder|User whereWechat($value)
  92. * @mixin \Eloquent
  93. */
  94. class User extends Authenticatable {
  95. use Notifiable;
  96. protected $table = 'user';
  97. protected $primaryKey = 'id';
  98. function scopeUid($query) {
  99. return $query->whereId(Auth::id());
  100. }
  101. function payment() {
  102. return $this->hasMany(Payment::class, 'user_id', 'id');
  103. }
  104. function subscribe() {
  105. return $this->hasOne(UserSubscribe::class, 'user_id', 'id');
  106. }
  107. function referral() {
  108. return $this->hasOne(User::class, 'id', 'referral_uid');
  109. }
  110. function getCreditAttribute($value) {
  111. return $value / 100;
  112. }
  113. function setCreditAttribute($value) {
  114. return $this->attributes['credit'] = $value * 100;
  115. }
  116. }