ReferralApply.php 1.1 KB

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