User.php 824 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Http\Models;
  3. use Illuminate\Notifications\Notifiable;
  4. use Illuminate\Foundation\Auth\User as Authenticatable;
  5. /**
  6. * 用户信息
  7. * Class User
  8. *
  9. * @package App\Http\Models
  10. */
  11. class User extends Authenticatable
  12. {
  13. use Notifiable;
  14. protected $table = 'user';
  15. protected $primaryKey = 'id';
  16. function payment()
  17. {
  18. return $this->hasMany(Payment::class, 'user_id', 'id');
  19. }
  20. function label()
  21. {
  22. return $this->hasMany(UserLabel::class, 'user_id', 'id');
  23. }
  24. function referral()
  25. {
  26. return $this->hasOne(User::class, 'id', 'referral_uid');
  27. }
  28. function getBalanceAttribute($value)
  29. {
  30. return $value / 100;
  31. }
  32. function setBalanceAttribute($value)
  33. {
  34. return $this->attributes['balance'] = $value * 100;
  35. }
  36. }