UserTrafficModifyLog.php 731 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Http\Models;
  3. use Eloquent;
  4. use Illuminate\Database\Eloquent\Model;
  5. /**
  6. * 用户流量变动记录
  7. * Class UserTrafficModifyLog
  8. *
  9. * @package App\Http\Models
  10. * @mixin Eloquent
  11. */
  12. class UserTrafficModifyLog extends Model
  13. {
  14. protected $table = 'user_traffic_modify_log';
  15. protected $primaryKey = 'id';
  16. // 关联账号
  17. function user()
  18. {
  19. return $this->hasOne(User::class, 'id', 'user_id');
  20. }
  21. // 关联订单
  22. function order()
  23. {
  24. return $this->hasOne(Order::class, 'oid', 'order_id');
  25. }
  26. function getBeforeAttribute($value)
  27. {
  28. return $this->attributes['before'] = flowAutoShow($value);
  29. }
  30. function getAfterAttribute($value)
  31. {
  32. return $this->attributes['after'] = flowAutoShow($value);
  33. }
  34. }