ReferralApply.php 971 B

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