ReferralLog.php 935 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 ref_user()
  19. {
  20. return $this->hasOne(User::class, 'id', 'ref_user_id');
  21. }
  22. function order()
  23. {
  24. return $this->hasOne(Order::class, 'oid', 'order_id');
  25. }
  26. function getAmountAttribute($value)
  27. {
  28. return $value / 100;
  29. }
  30. function setAmountAttribute($value)
  31. {
  32. $this->attributes['amount'] = $value * 100;
  33. }
  34. function getRefAmountAttribute($value)
  35. {
  36. return $value / 100;
  37. }
  38. function setRefAmountAttribute($value)
  39. {
  40. $this->attributes['ref_amount'] = $value * 100;
  41. }
  42. }