User.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. namespace App\Http\Models;
  3. use Auth;
  4. use Eloquent;
  5. use Illuminate\Database\Eloquent\Builder;
  6. use Illuminate\Database\Eloquent\Collection;
  7. use Illuminate\Foundation\Auth\User as Authenticatable;
  8. use Illuminate\Notifications\DatabaseNotification;
  9. use Illuminate\Notifications\DatabaseNotificationCollection;
  10. use Illuminate\Notifications\Notifiable;
  11. use Illuminate\Support\Carbon;
  12. /**
  13. * 用户信息
  14. * Class User
  15. *
  16. * @package App\Http\Models
  17. * @mixin Eloquent
  18. * @property int $id
  19. * @property string $username 用户名
  20. * @property string $password 密码
  21. * @property int $port 代理端口
  22. * @property string $passwd 代理密码
  23. * @property string $vmess_id V2Ray用户ID
  24. * @property int $transfer_enable 可用流量,单位字节,默认1TiB
  25. * @property int $u 已上传流量,单位字节
  26. * @property int $d 已下载流量,单位字节
  27. * @property int $t 最后使用时间
  28. * @property string|null $ip 最后连接IP
  29. * @property int $enable 代理状态
  30. * @property string $method 加密方式
  31. * @property string $protocol 协议
  32. * @property string|null $protocol_param 协议参数
  33. * @property string $obfs 混淆
  34. * @property string|null $obfs_param 混淆参数
  35. * @property int $speed_limit_per_con 单连接限速,默认10G,为0表示不限速,单位Byte
  36. * @property int $speed_limit_per_user 单用户限速,默认10G,为0表示不限速,单位Byte
  37. * @property string|null $wechat 微信
  38. * @property string|null $qq QQ
  39. * @property string $usage 用途:1-手机、2-电脑、3-路由器、4-其他
  40. * @property int $pay_way 付费方式:0-免费、1-季付、2-月付、3-半年付、4-年付
  41. * @property int $balance 余额,单位分
  42. * @property string|null $enable_time 开通日期
  43. * @property string $expire_time 过期时间
  44. * @property int $ban_time 封禁到期时间
  45. * @property string|null $remark 备注
  46. * @property int $level 等级:可定义名称
  47. * @property int $is_admin 是否管理员:0-否、1-是
  48. * @property string $reg_ip 注册IP
  49. * @property int $last_login 最后登录时间
  50. * @property int $referral_uid 邀请人
  51. * @property string|null $reset_time 流量重置日期,NULL表示不重置
  52. * @property int $invite_num 可生成邀请码数
  53. * @property int $status 状态:-1-禁用、0-未激活、1-正常
  54. * @property string|null $remember_token
  55. * @property Carbon|null $created_at
  56. * @property Carbon|null $updated_at
  57. * @property-read Collection|UserLabel[] $label
  58. * @property-read int|null $label_count
  59. * @property-read Level $levelList
  60. * @property-read DatabaseNotificationCollection|DatabaseNotification[] $notifications
  61. * @property-read int|null $notifications_count
  62. * @property-read Collection|Payment[] $payment
  63. * @property-read int|null $payment_count
  64. * @property-read User $referral
  65. * @property-read UserSubscribe $subscribe
  66. * @method static Builder|User newModelQuery()
  67. * @method static Builder|User newQuery()
  68. * @method static Builder|User query()
  69. * @method static Builder|User uid()
  70. * @method static Builder|User whereBalance($value)
  71. * @method static Builder|User whereBanTime($value)
  72. * @method static Builder|User whereCreatedAt($value)
  73. * @method static Builder|User whereD($value)
  74. * @method static Builder|User whereEnable($value)
  75. * @method static Builder|User whereEnableTime($value)
  76. * @method static Builder|User whereExpireTime($value)
  77. * @method static Builder|User whereId($value)
  78. * @method static Builder|User whereInviteNum($value)
  79. * @method static Builder|User whereIp($value)
  80. * @method static Builder|User whereIsAdmin($value)
  81. * @method static Builder|User whereLastLogin($value)
  82. * @method static Builder|User whereLevel($value)
  83. * @method static Builder|User whereMethod($value)
  84. * @method static Builder|User whereObfs($value)
  85. * @method static Builder|User whereObfsParam($value)
  86. * @method static Builder|User wherePasswd($value)
  87. * @method static Builder|User wherePassword($value)
  88. * @method static Builder|User wherePayWay($value)
  89. * @method static Builder|User wherePort($value)
  90. * @method static Builder|User whereProtocol($value)
  91. * @method static Builder|User whereProtocolParam($value)
  92. * @method static Builder|User whereQq($value)
  93. * @method static Builder|User whereReferralUid($value)
  94. * @method static Builder|User whereRegIp($value)
  95. * @method static Builder|User whereRemark($value)
  96. * @method static Builder|User whereRememberToken($value)
  97. * @method static Builder|User whereResetTime($value)
  98. * @method static Builder|User whereSpeedLimitPerCon($value)
  99. * @method static Builder|User whereSpeedLimitPerUser($value)
  100. * @method static Builder|User whereStatus($value)
  101. * @method static Builder|User whereT($value)
  102. * @method static Builder|User whereTransferEnable($value)
  103. * @method static Builder|User whereU($value)
  104. * @method static Builder|User whereUpdatedAt($value)
  105. * @method static Builder|User whereUsage($value)
  106. * @method static Builder|User whereUsername($value)
  107. * @method static Builder|User whereVmessId($value)
  108. * @method static Builder|User whereWechat($value)
  109. */
  110. class User extends Authenticatable
  111. {
  112. use Notifiable;
  113. protected $table = 'user';
  114. protected $primaryKey = 'id';
  115. function scopeUid($query)
  116. {
  117. return $query->where('id', Auth::user()->id);
  118. }
  119. function levelList()
  120. {
  121. return $this->hasOne(Level::class, 'level', 'level');
  122. }
  123. function payment()
  124. {
  125. return $this->hasMany(Payment::class, 'user_id', 'id');
  126. }
  127. function label()
  128. {
  129. return $this->hasMany(UserLabel::class, 'user_id', 'id');
  130. }
  131. function subscribe()
  132. {
  133. return $this->hasOne(UserSubscribe::class, 'user_id', 'id');
  134. }
  135. function referral()
  136. {
  137. return $this->hasOne(User::class, 'id', 'referral_uid');
  138. }
  139. function getBalanceAttribute($value)
  140. {
  141. return $value/100;
  142. }
  143. function setBalanceAttribute($value)
  144. {
  145. return $this->attributes['balance'] = $value*100;
  146. }
  147. }