UserBalanceLog.php 1006 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace App\Http\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. /**
  5. * 账号余额操作日志
  6. * Class UserBalanceLog
  7. *
  8. * @package App\Http\Models
  9. * @mixin \Eloquent
  10. */
  11. class UserBalanceLog extends Model
  12. {
  13. protected $table = 'user_balance_log';
  14. protected $primaryKey = 'id';
  15. public $timestamps = false;
  16. function user()
  17. {
  18. return $this->hasOne(User::class, 'id', 'user_id');
  19. }
  20. function getBeforeAttribute($value)
  21. {
  22. return $value / 100;
  23. }
  24. function setBeforeAttribute($value)
  25. {
  26. return $this->attributes['before'] = $value * 100;
  27. }
  28. function getAfterAttribute($value)
  29. {
  30. return $value / 100;
  31. }
  32. function setAfterAttribute($value)
  33. {
  34. return $this->attributes['after'] = $value * 100;
  35. }
  36. function getAmountAttribute($value)
  37. {
  38. return $value / 100;
  39. }
  40. function setAmountAttribute($value)
  41. {
  42. return $this->attributes['amount'] = $value * 100;
  43. }
  44. }