ReferralApply.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace App\Http\Models;
  3. use Auth;
  4. use Eloquent;
  5. use Illuminate\Database\Eloquent\Builder;
  6. use Illuminate\Database\Eloquent\Model;
  7. use Illuminate\Support\Carbon;
  8. /**
  9. * 返利申请
  10. * Class ReferralApply
  11. *
  12. * @package App\Http\Models
  13. * @mixin Eloquent
  14. * @property int $id
  15. * @property int $user_id 用户ID
  16. * @property int $before 操作前可提现金额,单位分
  17. * @property int $after 操作后可提现金额,单位分
  18. * @property int $amount 本次提现金额,单位分
  19. * @property string $link_logs 关联返利日志ID,例如:1,3,4
  20. * @property int $status 状态:-1-驳回、0-待审核、1-审核通过待打款、2-已打款
  21. * @property Carbon|null $created_at 创建时间
  22. * @property Carbon|null $updated_at 最后更新时间
  23. * @property-read User $User
  24. * @method static Builder|ReferralApply newModelQuery()
  25. * @method static Builder|ReferralApply newQuery()
  26. * @method static Builder|ReferralApply query()
  27. * @method static Builder|ReferralApply uid()
  28. * @method static Builder|ReferralApply whereAfter($value)
  29. * @method static Builder|ReferralApply whereAmount($value)
  30. * @method static Builder|ReferralApply whereBefore($value)
  31. * @method static Builder|ReferralApply whereCreatedAt($value)
  32. * @method static Builder|ReferralApply whereId($value)
  33. * @method static Builder|ReferralApply whereLinkLogs($value)
  34. * @method static Builder|ReferralApply whereStatus($value)
  35. * @method static Builder|ReferralApply whereUpdatedAt($value)
  36. * @method static Builder|ReferralApply whereUserId($value)
  37. */
  38. class ReferralApply extends Model
  39. {
  40. protected $table = 'referral_apply';
  41. protected $primaryKey = 'id';
  42. function scopeUid($query)
  43. {
  44. return $query->whereUserId(Auth::user()->id);
  45. }
  46. function User()
  47. {
  48. return $this->hasOne(User::class, 'id', 'user_id');
  49. }
  50. function getBeforeAttribute($value)
  51. {
  52. return $value/100;
  53. }
  54. function setBeforeAttribute($value)
  55. {
  56. $this->attributes['before'] = $value*100;
  57. }
  58. function getAfterAttribute($value)
  59. {
  60. return $value/100;
  61. }
  62. function setAfterAttribute($value)
  63. {
  64. $this->attributes['after'] = $value*100;
  65. }
  66. function getAmountAttribute($value)
  67. {
  68. return $value/100;
  69. }
  70. function setAmountAttribute($value)
  71. {
  72. $this->attributes['amount'] = $value*100;
  73. }
  74. }