ReferralApply.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 = ['link_logs' => 'array'];
  13. public function scopeUid($query)
  14. {
  15. return $query->whereUserId(Auth::id());
  16. }
  17. public function user(): BelongsTo
  18. {
  19. return $this->belongsTo(User::class);
  20. }
  21. public function getBeforeAttribute($value)
  22. {
  23. return $value / 100;
  24. }
  25. public function setBeforeAttribute($value): void
  26. {
  27. $this->attributes['before'] = $value * 100;
  28. }
  29. public function getAfterAttribute($value)
  30. {
  31. return $value / 100;
  32. }
  33. public function setAfterAttribute($value): void
  34. {
  35. $this->attributes['after'] = $value * 100;
  36. }
  37. public function getAmountAttribute($value)
  38. {
  39. return $value / 100;
  40. }
  41. public function setAmountAttribute($value): void
  42. {
  43. $this->attributes['amount'] = $value * 100;
  44. }
  45. }