UserDataModifyLog.php 923 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Casts\Attribute;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  6. /**
  7. * 用户流量变动记录.
  8. */
  9. class UserDataModifyLog extends Model
  10. {
  11. public const UPDATED_AT = null;
  12. protected $table = 'user_data_modify_log';
  13. protected $guarded = [];
  14. // 关联账号
  15. public function user(): BelongsTo
  16. {
  17. return $this->belongsTo(User::class);
  18. }
  19. // 关联订单
  20. public function order(): BelongsTo
  21. {
  22. return $this->belongsTo(Order::class);
  23. }
  24. public function before(): Attribute
  25. {
  26. return Attribute::make(
  27. get: static fn (int $value) => formatBytes($value),
  28. );
  29. }
  30. public function after(): Attribute
  31. {
  32. return Attribute::make(
  33. get: static fn (int $value) => formatBytes($value),
  34. );
  35. }
  36. }