UserBalanceLog.php 993 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. */
  10. class UserBalanceLog extends Model
  11. {
  12. protected $table = 'user_balance_log';
  13. protected $primaryKey = 'id';
  14. public $timestamps = false;
  15. public function User()
  16. {
  17. return $this->hasOne(User::class, 'id', 'user_id');
  18. }
  19. function getBeforeAttribute($value)
  20. {
  21. return $value / 100;
  22. }
  23. function setBeforeAttribute($value)
  24. {
  25. return $this->attributes['before'] = $value * 100;
  26. }
  27. function getAfterAttribute($value)
  28. {
  29. return $value / 100;
  30. }
  31. function setAfterAttribute($value)
  32. {
  33. return $this->attributes['after'] = $value * 100;
  34. }
  35. function getAmountAttribute($value)
  36. {
  37. return $value / 100;
  38. }
  39. function setAmountAttribute($value)
  40. {
  41. return $this->attributes['amount'] = $value * 100;
  42. }
  43. }