ReferralLog.php 834 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Http\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. /**
  5. * 返利日志
  6. * Class ReferralLog
  7. *
  8. * @package App\Http\Models
  9. */
  10. class ReferralLog extends Model
  11. {
  12. protected $table = 'referral_log';
  13. protected $primaryKey = 'id';
  14. function user()
  15. {
  16. return $this->hasOne(User::class, 'id', 'user_id');
  17. }
  18. function order()
  19. {
  20. return $this->hasOne(Order::class, 'oid', 'order_id');
  21. }
  22. function getAmountAttribute($value)
  23. {
  24. return $value / 100;
  25. }
  26. function setAmountAttribute($value)
  27. {
  28. $this->attributes['amount'] = $value * 100;
  29. }
  30. function getRefAmountAttribute($value)
  31. {
  32. return $value / 100;
  33. }
  34. function setRefAmountAttribute($value)
  35. {
  36. $this->attributes['ref_amount'] = $value * 100;
  37. }
  38. }