UserCreditLog.php 1.1 KB

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