UserBalanceLog.php 1.1 KB

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