User.php 8.6 KB

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