UserCreditLog.php 960 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. public const UPDATED_AT = null;
  10. protected $table = 'user_credit_log';
  11. public function user(): BelongsTo {
  12. return $this->belongsTo(User::class);
  13. }
  14. public function order(): BelongsTo {
  15. return $this->belongsTo(Order::class);
  16. }
  17. public function getBeforeAttribute($value) {
  18. return $value / 100;
  19. }
  20. public function setBeforeAttribute($value) {
  21. return $this->attributes['before'] = $value * 100;
  22. }
  23. public function getAfterAttribute($value) {
  24. return $value / 100;
  25. }
  26. public function setAfterAttribute($value) {
  27. return $this->attributes['after'] = $value * 100;
  28. }
  29. public function getAmountAttribute($value) {
  30. return $value / 100;
  31. }
  32. public function setAmountAttribute($value) {
  33. return $this->attributes['amount'] = $value * 100;
  34. }
  35. }