UserTrafficModifyLog.php 790 B

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