UserTrafficModifyLog.php 898 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. * @property-read \App\Http\Models\Order $Order
  10. * @property-read \App\Http\Models\User $User
  11. * @mixin \Eloquent
  12. */
  13. class UserTrafficModifyLog extends Model
  14. {
  15. protected $table = 'user_traffic_modify_log';
  16. protected $primaryKey = 'id';
  17. // 关联账号
  18. public function User()
  19. {
  20. return $this->hasOne(User::class, 'id', 'user_id');
  21. }
  22. // 关联订单
  23. public function Order()
  24. {
  25. return $this->hasOne(Order::class, 'oid', 'order_id');
  26. }
  27. function getBeforeAttribute($value)
  28. {
  29. return $this->attributes['before'] = flowAutoShow($value);
  30. }
  31. function getAfterAttribute($value)
  32. {
  33. return $this->attributes['after'] = flowAutoShow($value);
  34. }
  35. }