User.php 635 B

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