UserBalanceLog.php 893 B

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