ReferralApply.php 1.0 KB

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