ReferralApply.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace App\Http\Models;
  3. use Auth;
  4. use Illuminate\Database\Eloquent\Model;
  5. /**
  6. * 返利申请
  7. * Class ReferralApply
  8. *
  9. * @package App\Http\Models
  10. * @mixin \Eloquent
  11. */
  12. class ReferralApply extends Model
  13. {
  14. protected $table = 'referral_apply';
  15. protected $primaryKey = 'id';
  16. function scopeUid($query)
  17. {
  18. return $query->where('user_id', Auth::user()->id);
  19. }
  20. function User()
  21. {
  22. return $this->hasOne(User::class, 'id', 'user_id');
  23. }
  24. function getBeforeAttribute($value)
  25. {
  26. return $value / 100;
  27. }
  28. function setBeforeAttribute($value)
  29. {
  30. $this->attributes['before'] = $value * 100;
  31. }
  32. function getAfterAttribute($value)
  33. {
  34. return $value / 100;
  35. }
  36. function setAfterAttribute($value)
  37. {
  38. $this->attributes['after'] = $value * 100;
  39. }
  40. function getAmountAttribute($value)
  41. {
  42. return $value / 100;
  43. }
  44. function setAmountAttribute($value)
  45. {
  46. $this->attributes['amount'] = $value * 100;
  47. }
  48. }